利用SharpZipLib进行文件的压缩和解压缩
2007-02-23 16:13
411 查看
首先需要在项目里引用SharpZipLib.dll。然后修改其中的关于压缩和解压缩的类。实现源码如下:
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.GZip;
namespace Compression
现在再来看看解压文件类的源码
using System;
using System.Text;
using System.Collections;
using System.IO;
using System.Diagnostics;
using System.Runtime.Serialization.Formatters.Binary;
using System.Data;
using ICSharpCode.SharpZipLib.BZip2;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using ICSharpCode.SharpZipLib.GZip;
namespace DeCompression
有了压缩和解压缩的类以后,就要在窗体里调用了。怎么?是新手,不会调用?Ok,接着往下看如何在窗体里调用。
首先在窗体里放置两个命令按钮(不要告诉我你不会放啊~),然后编写以下源码
/// <summary>
/// 调用源码
/// </summary>
private void button2_Click_1(object sender, System.EventArgs e)
{
string []FileProperties=new string[2];
FileProperties[0]="C:/unzipped/";//待压缩文件目录
FileProperties[1]="C:/zip/a.zip"; //压缩后的目标文件
ZipClass Zc=new ZipClass();
Zc.ZipFileMain(FileProperties);
}
private void button2_Click(object sender, System.EventArgs e)
{
string []FileProperties=new string[2];
FileProperties[0]="C:/zip/test.zip";//待解压的文件
FileProperties[1]="C:/unzipped/";//解压后放置的目标目录
UnZipClass UnZc=new UnZipClass();
UnZc.UnZip(FileProperties);
}
好了,到此为止,如何压缩和解压缩的类都已经完成了
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.GZip;
namespace Compression
现在再来看看解压文件类的源码
using System;
using System.Text;
using System.Collections;
using System.IO;
using System.Diagnostics;
using System.Runtime.Serialization.Formatters.Binary;
using System.Data;
using ICSharpCode.SharpZipLib.BZip2;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using ICSharpCode.SharpZipLib.GZip;
namespace DeCompression
有了压缩和解压缩的类以后,就要在窗体里调用了。怎么?是新手,不会调用?Ok,接着往下看如何在窗体里调用。
首先在窗体里放置两个命令按钮(不要告诉我你不会放啊~),然后编写以下源码
/// <summary>
/// 调用源码
/// </summary>
private void button2_Click_1(object sender, System.EventArgs e)
{
string []FileProperties=new string[2];
FileProperties[0]="C:/unzipped/";//待压缩文件目录
FileProperties[1]="C:/zip/a.zip"; //压缩后的目标文件
ZipClass Zc=new ZipClass();
Zc.ZipFileMain(FileProperties);
}
private void button2_Click(object sender, System.EventArgs e)
{
string []FileProperties=new string[2];
FileProperties[0]="C:/zip/test.zip";//待解压的文件
FileProperties[1]="C:/unzipped/";//解压后放置的目标目录
UnZipClass UnZc=new UnZipClass();
UnZc.UnZip(FileProperties);
}
好了,到此为止,如何压缩和解压缩的类都已经完成了
相关文章推荐
- 利用SharpZipLib进行文件的压缩和解压缩
- 利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩收藏
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- [转贴]在C#中利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- 利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩
- C#利用SharpZipLib进行文件的压缩和解压缩
- 利用SharpZipLib进行文件的压缩和解压缩
- 在C#中利用SharpZipLib进行文件的压缩和解压缩收藏
- 在C#中利用SharpZipLib进行文件的压缩和解压缩