c#解压文件时,无法读取解压文件
浅浅小乔 2015-09-07 02:47:09 现在做一个项目,直接获取该压缩文件的内容,不保存解压文件。遇到了问题,求解!
public Stream unZip(string path)
{
try
{
ZipInputStream s = new ZipInputStream(File.OpenRead(path));
MemoryStream ms = new MemoryStream();
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
int i = 2048;
byte[] b = new byte[theEntry.Size];
while (s.Read(b, 0, b.Length) > 0)
{
ms.Write(b, 0, b.Length);
}
}
s.Close();
return ms;
}
catch (Exception ex)
{
string result = ex.Message;
return null;
}
}