c 解壓zip 進度 C 壓縮解壓zip 檔案

2021-10-13 08:25:15 字數 1510 閱讀 8048

1 ///

2 ///zip 壓縮檔案3 ///

4 public classzip5 10 #region 加壓方法

11 ///

14 /// 被壓縮的資料夾夾路徑

15 /// 生成壓縮檔案的路徑,為空則預設與被壓縮資料夾同一級目錄,名稱為:資料夾名+.zip

16 /// 出錯資訊

17 /// 是否壓縮成功

18 public static bool zipfile(string dirpath, string zipfilepath, out stringerr)19 26 if (!directory.exists(dirpath))27 31 //壓縮檔案名為空時使用資料夾名+.zip

32 if (zipfilepath == string.empty)33 38 zipfilepath = dirpath + ".zip";39 }40

41 try

42 while (sourcebytes > 0);61 }62 }63 s.finish();64 s.close();65 }66 }67 catch(exception ex)68 72 return true;73 }74 #endregion

76 #region 解壓

77 ///

78 ///功能:解壓zip格式的檔案。79 ///

80 /// 壓縮檔案路徑

81 /// 解壓檔案存放路徑,為空時預設與壓縮檔案同一級目錄下,跟壓縮檔案同名的資料夾

82 /// 出錯資訊

83 /// 解壓是否成功

84 public static bool unzipfile(string zipfilepath, string unzipdir, out stringerr)85 92 if (!file.exists(zipfilepath))93 97 //解壓資料夾為空時預設與壓縮檔案同一級目錄下,跟壓縮檔案同名的資料夾

98 if (unzipdir == string.empty)99 unzipdir =zipfilepath.replace(path.getfilename(zipfilepath), path.getfilenamewithoutextension(zipfilepath));100 if (!unzipdir.endswith("//"))101 unzipdir += "//";102 if (!directory.exists(unzipdir))103 directory.createdirectory(unzipdir);104

105 try

106 119 if (!directoryname.endswith("//"))120 directoryname += "//";121 if (filename !=string.empty)122 135 else

136 139 }140 }141 }142 }//while

143 }144 }145 catch(exception ex)146 150 return true;151 }//解壓結束

152 #endregion

c 解壓zip 進度 C 實現Zip壓縮解壓例項

1 usingsystem 2 usingsystem.collections.generic 3 usingsystem.linq 4 usingsystem.text 5 usingsystem.io 6 usingicsharpcode.sharpziplib 7 usingicsharpco...

C 壓縮解壓Zip檔案

新增引用icsharpcode.sharpziplib.dll region 加壓方法 被壓縮的資料夾夾路徑 生成壓縮檔案的路徑,為空則預設與被壓縮資料夾同一級目錄,名稱為 資料夾名 zip 出錯資訊 是否壓縮成功 public static bool zipfile string dirpath,...

C 壓縮解壓zip 檔案

zip 壓縮檔案 public class zip region 加壓方法 功能 壓縮檔案 暫時只壓縮資料夾下一級目錄中的檔案,資料夾及其子級被忽略 被壓縮的資料夾夾路徑 生成壓縮檔案的路徑,為空則預設與被壓縮資料夾同一級目錄,名稱為 資料夾名 zip 出錯資訊 是否壓縮成功 public stat...