C# 打包 zip

时间:2016-07-23 06:25:19
【文件属性】:

文件名称:C# 打包 zip

文件大小:12KB

文件格式:CS

更新时间:2016-07-23 06:25:19

C# 打包 zip

private void Unzip(string filePath1, string urlid) { if (Directory.Exists(Server.MapPath("ziptemp/" + urlid)) == false) { Directory.CreateDirectory(Server.MapPath("ziptemp/" + urlid)); } ZipInputStream s = new ZipInputStream(File.OpenRead(filePath1)); ZipEntry theEntry; while ((theEntry = s.GetNextEntry()) != null) { string fullname = Server.MapPath("ziptemp/" + urlid + "/" + theEntry.Name); string directoryName = Path.GetDirectoryName(fullname); string fileName = Path.GetFileName(fullname); if (!Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); if (fileName != String.Empty) { FileStream streamWriter = File.Create(fullname); int size = 2048; byte[] data = new byte[2048]; while (true) { size = s.Read(data, 0, data.Length); if (size > 0) streamWriter.Write(data, 0, size); else break; } streamWriter.Close(); } } s.Close(); }


网友评论

  • 已照样搞定,表扬
  • 很好用,谢谢