Class ZipHelper
- Namespace
- ZapLib
- Assembly
- ZapLib.dll
zip 壓縮類別輔助工具
public class ZipHelper
- Inheritance
-
ZipHelper
- Inherited Members
Constructors
ZipHelper(string, string)
建構子,建立壓縮工具初始化必要資訊
public ZipHelper(string foldername, string root = null)
Parameters
Properties
ErrorLogs
錯誤訊息紀錄
public List<string> ErrorLogs { get; }
Property Value
FileList
將被加入壓縮檔中的檔案列表
public List<(string, string, string)> FileList { get; }
Property Value
Folder
將被壓縮的目標目錄資訊物件
public DirectoryInfo Folder { get; }
Property Value
ZipDirName
將被壓縮的目標目錄名稱
public string ZipDirName { get; }
Property Value
ZipDist
最終壓縮檔案的實體路徑位置
public string ZipDist { get; }
Property Value
Methods
AddFile(string, string, string)
新增檔案到 zip 壓縮檔中
public void AddFile(string target_folder_path, string target_file_path, string newfilename = null)
Parameters
target_folder_pathstring放置在壓縮檔案中的目錄的相對路徑 (目錄將自動建立)
target_file_pathstring實體檔案放置位置
newfilenamestring檔案新名稱,如果沒給則使用原始名稱
ParseFolder(string)
解析相對路徑,但排除 . 與 .. 兩種格式的操作符號,回傳各層目錄名稱列表
public string[] ParseFolder(string path)
Parameters
pathstring相對路徑字串
Returns
- string[]
依照目錄階層回傳有序的目錄陣列
RemoveTmp()
刪除暫存檔案,此函數會在 Zip() 方法完成後自動呼叫
public bool RemoveTmp()
Returns
Zip()
壓縮檔案,並清除暫存檔
public bool Zip()
Returns
- bool
是否壓縮成功,如果壓縮成功可以從成員 ZipDist 取得 zip 檔案路徑