用了 Log4net 记录日志,如果没有 Log4net 的,将 Log4net 注释即可运行
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Collections;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip.Compression;
using log4net;
namespace FiSMDataClient.Service
{
public class ZipLib
{
private static readonly ILog LOG = LogManager.GetLogger(typeof(FileLib));
public ArrayList fileList = new ArrayList();
string changname=null;
#region 压缩文件
/// <summary>
/// 压缩多文件(调用之前先为fileList 赋值)
/// </summary>
/// <param name="outZipPath">输出Zip文件的全路径</param>
public void Compress(string outZipPath)
{
try
{
Crc32 crc = new Crc32();
ZipOutputStream zipStream = new ZipOutputStream(File.Create(outZipPath));
zipStream.SetLevel(9); // 0 - store only to 9 - means best compression
foreach (string file in FileList)
{
FileStream fStream = File.OpenRead(file);
byte[] buffer = new byte[fStream.Length];
fStream.Read(buffer, 0, buffer.Length);
string filename = file.Substring(file.LastIndexOf("//") + 1, file.Length - file.LastIndexOf("//") - 1);
ZipEntry entry = new ZipEntry(filename);
entry.DateTime = DateTime.Now;
entry.Size = fStream.Length;
fStream.Close();
crc.Reset();
crc.Update(buffer);
entry.Crc = crc.Value;
zipStream.PutNextEntry(entry);
zipStream.Wri