zoukankan      html  css  js  c++  java
  • 解压缩

    
    

    需要下载引用ICSharpCode.SharpZipLib.dll这个文件


    using
    ICSharpCode.SharpZipLib.Zip; using System.IO; ///////////////////////////////////调用//////////////////////////////////// string filePath = GetRootPath() + "UploadFiles\test\aaa.zip"; string destFilePath = GetRootPath() + "UploadFiles\test\"; UnZip(filePath, destFilePath, ""); ////////////////////////////////////////////////////////////////////////////// #region 解压 /// <summary> /// 解压 /// </summary> /// <param name="fileToUpZip">压缩文件路径</param> /// <param name="zipedFolder">解压文件存放路径,为空时默认创建文件夹</param> /// <param name="password">密码</param> public void UnZip(string fileToUpZip, string zipedFolder, string password) { if (!File.Exists(fileToUpZip)) { return; } if (!Directory.Exists(zipedFolder)) { Directory.CreateDirectory(zipedFolder); } ZipInputStream s = null; ZipEntry theEntry; string fileName; FileStream streamWriter = null; try { s = new ZipInputStream(File.OpenRead(fileToUpZip)); s.Password = password; while ((theEntry = s.GetNextEntry()) != null) { if (theEntry.Name != String.Empty) { fileName = Path.Combine(zipedFolder, theEntry.Name); //判断文件路径是否是文件夹 if (fileName.EndsWith("/") || fileName.EndsWith("\")) { Directory.CreateDirectory(fileName); continue; } streamWriter = File.Create(fileName); int size; byte[] data = new byte[2048]; while (true) { size = s.Read(data, 0, data.Length); if (size > 0) { streamWriter.Write(data, 0, size); } else { break; } } } } } finally { if (streamWriter != null) { streamWriter.Close(); } if (s != null) { s.Close(); } GC.Collect(); GC.Collect(1); } } #endregion
  • 相关阅读:
    小梦windows phone 8.1开发:语音朗读
    windows phone 8.1开发:socket通信聊天
    windows phone 8.1开发:触控和指针事件1
    Windows Phone 8.1开发:触控和指针事件2
    windows phone 8.1开发 onedrive操作详解
    windows phone 8.1开发SQlite数据库引用安装
    利用Register protocol实现网页调用桌面程序(类似迅雷、QQ等)
    windows phone 8.1开发SQlite数据库操作详解
    xrandr
    mongodb
  • 原文地址:https://www.cnblogs.com/deep-blue/p/5110001.html
Copyright © 2011-2022 走看看