[Asp.net] ziphelper online compression and decompression help class (implementation of sharpziplib)

Source: Internet
Author: User

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]

Refer to blog:

SharpZipLib example-lann-blog

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 /// Summary of ZipHelper
17 /// </summary>
18 publicclass ZipHelper
19 {
20 /// <summary>
21 // create a ZipHelper instance
22 /// </summary>
23 publicstaticreadonly ZipHelper Instance = new ZipHelper ();
24
25 private ziphelper (){}
26
27 /// <summary>
28 // compressed file
29 /// </Summary>
30 /// <Param name = "zipfilename"> file name </param>
31 // <Param name = "sourcedirectory"> source file directory </param>
32 publicvoid createzip (string zipfilename, string sourcedirectory)
33 {
34 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 // decompress the file
53 /// </summary>
54 // <param name = "zipFileName"> file name </param>
55 // <param name = "targetDirectory"> target file directory </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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.