Доброго времени суток!
Использую Ionic.zip. Создаю архив с кодировкой "cp866", имена отображаются нормально например в WinRar.
Вот вырезка кода:
if( p_bIsExist )
zip = ZipFile.Read( Program.m_sExecutablePath + m_sPath + p_sFileName + ".zip" );
else
zip = new ZipFile( Program.m_sExecutablePath + m_sPath + p_sFileName + ".zip" );
zip.UseUnicodeAsNecessary = true;
zip.ProvisionalAlternateEncoding = System.Text.Encoding.GetEncoding("cp866");
fs_Screenshot = new FileStream( m_FileNameAndPath, FileMode.Open );
p_sScreenshot = System.IO.Path.GetFileName( m_FileNameAndPath );
zip.AddEntry( p_sScreenshot, fs_Screenshot );
zip.Save();
fs_Screenshot.Close();
fs_Screenshot.Dispose();
zip.Dispose();
Но вот как дальше работать с файлами в архиве? Понятно что zip.RemoveEntry( "трали вали" ) и тд, но они требуют кодировку "cp866"!
Пробую перекодировать C# строки
ZipFile zip = ZipFile.Read( Program.m_sExecutablePath + m_Knowledge.p_FileContent.p_sPath + m_Knowledge.p_FileContent.p_sFileName + ".zip" );
zip.UseUnicodeAsNecessary = true;
zip.ProvisionalAlternateEncoding = System.Text.Encoding.GetEncoding("cp866");
string s = Encoding.GetEncoding("cp866").GetString( Encoding.Convert( Encoding.Unicode, Encoding.GetEncoding("cp866"), Encoding.Unicode.GetBytes(m_Knowledge.p_FileContent.p_sScreenshot) ) );
MessageBox.Show( s );
MemoryStream streamData = new MemoryStream();
zip[s].UseUnicodeAsNecessary = true; <- Сглючивает
zip[s].ProvisionalAlternateEncoding = System.Text.Encoding.GetEncoding("cp866");
zip[s].Extract( streamData );
fk.pictureBox1.Image = Image.FromStream( streamData );
streamData.Close();
Но в указанном месте сглючивает потому что zip[s] = null!
Вопросы:
В какой кодировке C# string'и?
Как правильно перекодировать?
Честно говоря с кодировками сталкиваюсь впервые, msdn и гугл пока не помогли.