一, 推荐使用CSharpZipLib库 , 因为DotNetZip没有测试出来
/// <summary> /// /// </summary> /// <param name="zipPath">zip的路径</param> /// <param name="fileName">zip中文本的名称</param> /// <returns></returns> public string GetZipStr(string zipPath, string fileName) { ZipInputStream zip = new ZipInputStream(File.OpenRead(zipPath)); FileStream filestream = new FileStream(zipPath, FileMode.Open, FileAccess.Read); ZipFile zipfile = new ZipFile(filestream); ZipEntry item; while ((item = zip.GetNextEntry()) != null) { if (item.Name == fileName) { using (StreamReader s = new StreamReader(zipfile.GetInputStream(item))) { return s.ReadToEnd(); } } } return null; }
二,结果
如各位读者有DotNetZip的实现方案, 请不吝赐教.