zoukankan      html  css  js  c++  java
  • [Asp.net]ZipHelper 在线压缩解压帮助类(SharpZipLib组件实现)

    SharpZipLib

    Available downloads

    Assemblies for .NET 1.1, .NET 2.0 (3.5, 4.0), .NET CF 1.0, .NET CF 2.0: Download [237 KB]

    Source code and samples Download [708 KB]

    Help file Download [1208 KB]

    参考博文:

    SharpZipLib使用示例 - lann - 博客园

    ZipHelper.cs

     

    1 using System;
    2  using System.Data;
    3  using System.Configuration;
    4  using System.Linq;
    5  using System.Web;
    6  using System.Web.Security;
    7 using System.Web.UI;
    8 using System.Web.UI.HtmlControls;
    9 using System.Web.UI.WebControls;
    10 using System.Web.UI.WebControls.WebParts;
    11 using System.Xml.Linq;
    12 using System.IO;
    13 using ICSharpCode.SharpZipLib.Zip;
    14
    15 ///<summary>
    16 ///ZipHelper 的摘要说明
    17 ///</summary>
    18 publicclass ZipHelper
    19 {
    20 ///<summary>
    21 /// 创建ZipHelper实例
    22 ///</summary>
    23 publicstaticreadonly ZipHelper Instance =new ZipHelper();
    24
    25 private ZipHelper() { }
    26
    27 ///<summary>
    28 /// 压缩文件
    29 ///</summary>
    30 ///<param name="zipFileName">文件名</param>
    31 ///<param name="sourceDirectory">源文件目录</param>
    32 publicvoid CreateZip(string zipFileName, string sourceDirectory)
    33 {
    34 FastZip fastZip =new FastZip();
    35
    36 try
    37 {
    38 fastZip.CreateEmptyDirectories =true;
    39 fastZip.CreateZip(zipFileName, sourceDirectory, true, "");
    40 }
    41 catch (Exception ex)
    42 {
    43 thrownew Exception(ex.Message);
    44 }
    45 finally
    46 {
    47 fastZip =null;
    48 }
    49 }
    50
    51 ///<summary>
    52 /// 解压文件
    53 ///</summary>
    54 ///<param name="zipFileName">文件名</param>
    55 ///<param name="targetDirectory">目标文件目录</param>
    56 publicvoid ExtractZip(string zipFileName, string targetDirectory)
    57 {
    58 FastZip fastZip =new FastZip();
    59
    60 try
    61 {
    62 fastZip.ExtractZip(zipFileName, targetDirectory, "");
    63 }
    64 catch (Exception ex)
    65 {
    66 thrownew Exception(ex.Message);
    67 }
    68 finally
    69 {
    70 fastZip =null;
    71 }
    72 }
    73 }
    74
  • 相关阅读:
    [POJ 2096]Collecting Bugs
    [SPOJ 375]Query on a tree
    [BZOJ 4423][AMPPZ2013]Bytehattan
    [BZOJ 2038][2009国家集训队]小Z的袜子(hose)
    [SDOI 2017]数字表格
    [NOI 2010]能量采集
    [HNOI 2014]世界树
    [HNOI 2016]序列
    [HNOI 2016]大数
    [HEOI 2014]大工程
  • 原文地址:https://www.cnblogs.com/JavCof/p/1802075.html
Copyright © 2011-2022 走看看