微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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;
		}

二,结果

B01.png


如各位读者有DotNetZip的实现方案, 请不吝赐教.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐