一直以来都是采用WinZIP进行压缩的,调用起来方便,而且公司也有版权,所以就没有考虑过其他的东东。不过唯一不足的地方就是需要安装(包括Win Zip和其Command Line Addon),而且需要让程序知道调用的WinZIP路径,配置起来不是很方便。
本次项目,考虑到程序的易配置性,决定采用另外别的方式进行压缩,找了找就找到了ICSharpCode的SharpZipLib组件,开源的,并且功能很强大:压缩、解压缩、加密等等一系列功能都有,而且调用起来也蛮方便的,于是决定采用该组件了。
同样,为了能够更好的为项目服务,也对该组件作了封装,调用更加简单。
using
System;
using System.IO;
using System.Collections;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.GZip;
namespace BenQ.Modias.Utility
... {
/**////<summary>
///******************************************************************
///** Creator : Venus Feng
///** Create Date : 2006-9-19 16:21
///** Modifier :
///** Modify Date :
///** Description : Use ICSharpZipLib to ZIP File
///**
///**
///** Version No : 1.0.0
///**
///******************************************************************
///</summary>
public class ZIPPER : IDisposable
...{
private string m_FolderToZIP;
private ArrayList m_FileNamesToZIP;
private string m_FileNameZipped;
private ZipOutputStream m_ZipStream = null;
private Crc32 m_Crc;
Begin for Public Properties#region Begin for Public Properties
/**//// <summary>
/// Folder Name to ZIP
/// Like "C:Test"
/// </summary>
public string FolderToZIP
...{
get ...{ return m_FolderToZIP; }
set ...{ m_FolderToZIP = value; }
}
/**//// <summary>
/// File Name to ZIP
/// Like "C:TestTest.txt"
/// </summary>
public ArrayList FileNamesToZIP
...{
using System.IO;
using System.Collections;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.GZip;
namespace BenQ.Modias.Utility
... {
/**////<summary>
///******************************************************************
///** Creator : Venus Feng
///** Create Date : 2006-9-19 16:21
///** Modifier :
///** Modify Date :
///** Description : Use ICSharpZipLib to ZIP File
///**
///**
///** Version No : 1.0.0
///**
///******************************************************************
///</summary>
public class ZIPPER : IDisposable
...{
private string m_FolderToZIP;
private ArrayList m_FileNamesToZIP;
private string m_FileNameZipped;
private ZipOutputStream m_ZipStream = null;
private Crc32 m_Crc;
Begin for Public Properties#region Begin for Public Properties
/**//// <summary>
/// Folder Name to ZIP
/// Like "C:Test"
/// </summary>
public string FolderToZIP
...{
get ...{ return m_FolderToZIP; }
set ...{ m_FolderToZIP = value; }
}
/**//// <summary>
/// File Name to ZIP
/// Like "C:TestTest.txt"
/// </summary>
public ArrayList FileNamesToZIP
...{