文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>ZipHelper 在线压缩解压帮助类(SharpZipLib组件实现)

ZipHelper 在线压缩解压帮助类(SharpZipLib组件实现)

时间:2010-08-18  来源:安布雷拉

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 public class ZipHelper
19 {
20 /// <summary>
21 /// 创建ZipHelper实例
22 /// </summary>
23 public static readonly 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 public void 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 throw new 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 public void 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 throw new Exception(ex.Message);
67 }
68 finally
69 {
70 fastZip = null;
71 }
72 }
73 }
74

 

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载