SharpZipLib壓縮解壓

2021-08-29 05:13:26 字數 1536 閱讀 2498

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.io;

using icsharpcode.sharpziplib.zip;

namespace test

///

/// zip中路徑

///

public string path

///

/// 絕對路徑

///

public string fullpath

}///

/// 遞迴獲取檔案目錄

/// 王洪岐 2011-11-22

///

///

///

///

public static void getfiles(string arrpath, listlistpath, string strmainpath)

);for (int i = 0; i < filelist.count; i++));}

getfiles(arrdir, listpath, strmainpath);}}

/// 源資料夾路徑

/// 目標檔案路徑

/// 從源資料夾中指定某檔案

/// -1=檔案不存在,0=未知錯誤,1=成功

public static int zipcompress(string arrpath, string topath)

if (string.isnullorempty(strmainpath))

//是檔案

if (file.exists(strn)));}

else

);for (int i = 0; i < filelist.count; i++));}

getfiles(directory.getdirectories(strn), listpath, strmainpath);}}

using (zipoutputstream s = new zipoutputstream(file.create(topath)))

while (sourcebytes > 0);}}

else

}s.finish();

s.close();

}return 1;

}catch

}///

/// 解壓縮

/// 王洪岐

///

///

///

///

public static int zipuncompress(string filepath,string topath)

tryelse if (!directory.exists(topath))

if (filename != string.empty)

else}}

}}}return 1;

}catch}}

}

利用SharpZipLib壓縮 解壓檔案

public class zipinfo 壓縮檔案 private void filetozip string path,string address 解壓到乙個目錄 public bool ziptofile string path,string addres s.close catch exce...

SharpZipLib 的使用 壓縮,解壓

sharpziplib 是乙個免費的zip操作類庫,可以利用它對 zip 等多種格式進行壓縮與解壓。前的版本為0.86。1 建立zip 檔案,並新增檔案 using zipfile zip zipfile.create e test.zip 2 將資料夾壓縮為檔案 new fastzip creat...

C 使用SharpZipLib壓縮解壓檔案

region 加壓解壓方法 被壓縮的資料夾夾路徑 生成壓縮檔案的路徑,為空則預設與被壓縮資料夾同一級目錄,名稱為 資料夾名 zip 出錯資訊 是否壓縮成功 public bool zipfile string dirpath,string zipfilepath,out string err if ...