Unity3D直接从Zip中读取文本数据
Unity3D直接从Zip中读取文本数据
一, 推荐使用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的实现方案, 请不吝赐教.
©著作权归作者所有:来自51CTO博客作者Aonaufly的原创作品,如需转载,请注明出处,否则将追究法律责任