110,536
社区成员
发帖
与我相关
我的任务
分享
public static void DeflateDecompress(string sourceFile, string targetFile)
{
using (System.IO.FileStream rStream = new System.IO.FileStream(sourceFile, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
System.IO.Compression.DeflateStream zipStream = new System.IO.Compression.DeflateStream(rStream, System.IO.Compression.CompressionMode.Decompress);
using (System.IO.FileStream wStream = new System.IO.FileStream(targetFile, System.IO.FileMode.Create, System.IO.FileAccess.Write))
{
while (true)
{
byte[] bf = new byte[2048];
int bytesread = zipStream.Read(bf, 0, 2048);
if (bytesread == 0)
break;
wStream.Write(bf, 0, bytesread);
}
wStream.Flush();
wStream.Close();
}
rStream.Close();
}
}