C 解壓縮檔案幫助類

2021-06-28 23:12:42 字數 1534 閱讀 1433

**如下圖:

/// /// 壓縮、解壓縮檔案類

///

public class ziphelper

else if (file.exists(sourcepath))

outputstream.finish(); //結束壓縮

outputstream.close();

fs.close();

result = true;

}catch (exception ex)

}return result;

}/// /// 壓縮資料夾

///

///

///

///

///

static void zipfolder(string sourcefolder, zipoutputstream outputstream, string topsourcefolder, bool zipcontent = true)

else if (file.exists(item.fullname))

else

", dirinfo.name, name);

}filestream fs = file.openread(fullname);

byte buffer = new byte[fs.length];

fs.read(buffer, 0, buffer.length);

zipentry entry = new zipentry(relativepath);

outputstream.putnextentry(entry); //為壓縮檔案流提供乙個容器

outputstream.write(buffer, 0, buffer.length);}}

}/// /// 解壓縮

///

/// 待解壓縮的zip檔案路徑

/// 解壓處理的檔案存放路徑

///

public static bool decompressionzip(string zippath, string destfolder)

while (entry != null)//如果解壓完ze則是null

\\", destfolder, path)));

}fs = new filestream(string.format("\\", destfolder, entry.name), filemode.openorcreate, fileaccess.readwrite);

byte buffer = new byte[1024];

int read = inputstream.read(buffer, 0, buffer.length);

while (read > 0)

fs.flush();

fs.close();

}entry = inputstream.getnextentry();}}

catch (exception ex)

}return result;

}}

C 解壓縮檔案

c 解壓縮檔案 例項化fastzip public static fastzip fz new fastzip 例項化fastzip 壓縮檔案 壓縮檔案的路徑與名稱 被壓縮的檔案路徑 解壓密碼 null代表無密碼 public static string filetozip string zipfi...

解壓縮檔案

public static fastzip fz new fastzip 壓縮檔案 壓縮檔案的路徑與名稱 被壓縮的檔案路徑 解壓密碼 null代表無密碼 public static string filetozip string zipfilepath,string filepath,string ...

解壓縮檔案

using system using system.collections.generic using system.linq using system.text using system.threading.tasks using system.io namespace commonhelper ...