zoukankan      html  css  js  c++  java
  • C#解压缩文件

    代码:

    #region 解压
    /// <summary>
    /// 解压
    /// </summary>
    public void UnZip(string zipPath, string targetPath)
    {
        using (FileStream fsZip = new FileStream(zipPath, FileMode.Open, FileAccess.Read))
        {
            using (ZipInputStream zipInputStream = new ZipInputStream(fsZip))
            {
    
                ZipEntry zipEntry;
                while ((zipEntry = zipInputStream.GetNextEntry()) != null)
                {
                    if (zipEntry.IsDirectory)
                    {
                        Directory.CreateDirectory(Path.Combine(targetPath, zipEntry.Name));
                    }
                    else
                    {
                        if (zipEntry.Name != String.Empty)
                        {
                            //解压文件到指定的目录
                            using (FileStream fsFile = new FileStream(Path.Combine(targetPath, zipEntry.Name), FileMode.Create, FileAccess.Write))
                            {
                                int size;
                                byte[] data = new byte[1024 * 1024];
                                while ((size = zipInputStream.Read(data, 0, data.Length)) > 0)
                                {
                                    fsFile.Write(data, 0, size);
                                }
                            }
                        }
                    }
                }//end while
            }
        }
    }
    #endregion
    View Code
  • 相关阅读:
    接口测试01
    mysql主从
    linux下配置JDK
    linux常用命令
    mysql基本语句
    线程与进程
    loadrunner函数
    设计模式-模板方法模式
    设计原则-CRP合成复用原则
    设计原则-LOD迪米特法则
  • 原文地址:https://www.cnblogs.com/s0611163/p/5407722.html
Copyright © 2011-2022 走看看