我想下載並提取C#中的zip文件,特別是DotNetZip。提取內存中的zip文件與C#失敗DotNetZip
當我運行這段代碼...
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(reportUrl);
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
Stream stream = response.GetResponseStream();
MemoryStream ms = new MemoryStream();
stream.CopyTo(ms);
ms.Seek(0, 0);
ZipInputStream zip = new ZipInputStream(ms);
zip.Seek(0, 0);
ZipEntry e = zip.GetNextEntry();
string s = e.FileName;
MemoryStream ms2 = new MemoryStream();
e.Extract(ms2);
後的提取方法執行,我得到...
$exception {"Object reference not set to an instance of an object."} System.Exception {System.NullReferenceException}
有什麼想法?謝謝!
我的直接想法是InputStream爲空 – Ell 2011-06-16 18:48:47
你試過使用不同的memorystream實例嗎? – 2011-06-16 18:49:39
「解壓縮方法執行後」是什麼意思?拋出異常之前它是否正確執行? Extract後的下一行代碼是什麼? – 2011-06-16 18:51:46