1
我有decomress gzip的問題:問題與解壓縮,GZipStream
string fileData = string.Empty;
// byte[] starts with 31 and 139
var gzBuffer = entity.Data.Skip(pos).ToArray();
using (GZipStream stream = new GZipStream(new MemoryStream(gzBuffer),CompressionMode.Decompress))
{
const int size = 4096;
byte[] buffer = new byte[size];
using (MemoryStream memory = new MemoryStream())
{
int count = 0;
do
{
count = stream.Read(buffer, 0, size);
if (count > 0)
{
memory.Write(buffer, 0, count);
}
} while (count > 0);
fileData = Encoding.UTF8.GetString(memory.ToArray());
}
}
在調試程序,計數等於百達0問題出在哪裏?
謝謝。
此流是如何壓縮的?我在過去也經歷過這個問題,錯誤實際上是在壓縮邏輯中。 – 2011-05-15 13:21:33
你檢查過gzbuffer嗎?也許它是空的。 – Saleh 2011-05-15 13:24:05
@ Jan-Peter Vos:我不能肯定地說,因爲這條消息來自網絡。 – user348173 2011-05-15 13:28:31