Это мой код
Код: Выделить всё
class GZOutputStream : ZOutputStream
{
public GZOutputStream(Stream in_Renamed) : base(in_Renamed)
{
byte[] dictionary = System.Text.ASCIIEncoding.ASCII.GetBytes(sDictionary);
z.inflateSetDictionary(dictionary, dictionary.Length);
}
public GZOutputStream(Stream in_Renamed, int level) : base(in_Renamed, level)
{
byte[] dictionary = System.Text.ASCIIEncoding.ASCII.GetBytes(sDictionary);
z.deflateSetDictionary(dictionary, dictionary.Length);
}
}
public static byte[] compressString(string source)
{
byte[] buffer = System.Text.Encoding.Default.GetBytes (source);
MemoryStream memOutput = new MemoryStream ();
GZOutputStream zipOut = new GZOutputStream(memOutput, zlibConst.Z_DEFAULT_COMPRESSION);
zipOut.Write(buffer, 0, buffer.Length);
zipOut.finish();
memOutput.Seek(0, SeekOrigin.Begin);
byte[] result = memOutput.ToArray();
return result;
}
public static byte[] deCompressString(string source)
{
byte[] buffer = System.Text.Encoding.Default.GetBytes (source);
MemoryStream memOutput = new MemoryStream ();
GZOutputStream zipOut = new GZOutputStream(memOutput);
zipOut.Write(buffer, 0, buffer.Length);
zipOut.finish();
memOutput.Seek(0, SeekOrigin.Begin);
byte[] result = memOutput.ToArray();
return result;
}
ZStreamException: раздувание:
zlib.ZOutputStream.Write (System.Byte[] b1, Int32 off, Int32 len)
Итак, каково решение?< /п>
Подробнее здесь: https://stackoverflow.com/questions/315 ... in-c-sharp
Мобильная версия