Practical experience in using Sharpzip compression and decompression

Source: Internet
Author: User
Tags zip
First, in the http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx download source, find "ZipConstants.cs" modified
public static string ConvertToString (byte[] data)
{
Return encoding.getencoding ("gb2312"). GetString (data, 0, data.) Length);
Return Encoding.ASCII.GetString (data,0, data. Length);
}

public static byte[] Converttoarray (String str)
{
Return encoding.getencoding ("gb2312"). GetBytes (str);
return Encoding.ASCII.GetBytes (str);
}
So you can support the Chinese name.
Here's what I wrote about the compression and decompression code:
Using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Web;
Using System.Web.SessionState;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.HtmlControls;
Using ICSharpCode.SharpZipLib.Zip;
Namespace OA
{
<summary>
Summary description of the WebForm1.
</summary>
public class WebForm1:System.Web.UI.Page
{
public string Serverdir;
private void Page_Load (object sender, System.EventArgs e)
{
Place user code here to initialize page
This. Serverdir = Page.mappath (".");
This. ZipFile ("01.txt*02.txt*000.zip"); Just examples, the specific people to achieve
This. ZipFile ("01.txt*02.txt*001.zip");
This. Unzipfile ("000.zip*001.zip");
}
public string Shortdir (string s)
{
To convert a file's absolute path to a relative path
String D=s.replace (Serverdir, "");
return D;
}
Compressed file p Returns a list of files for the client: filename + name of the compressed package
public void ZipFile (string p)

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.