Table of Contents

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

foldername string

壓縮檔案的目錄名稱,最終檔案將會加上 .zip

root string

存放的位置

Properties

ErrorLogs

錯誤訊息紀錄

public List<string> ErrorLogs { get; }

Property Value

List<string>

FileList

將被加入壓縮檔中的檔案列表

public List<(string, string, string)> FileList { get; }

Property Value

List<(string, string, string)>

Folder

將被壓縮的目標目錄資訊物件

public DirectoryInfo Folder { get; }

Property Value

DirectoryInfo

ZipDirName

將被壓縮的目標目錄名稱

public string ZipDirName { get; }

Property Value

string

ZipDist

最終壓縮檔案的實體路徑位置

public string ZipDist { get; }

Property Value

string

Methods

AddFile(string, string, string)

新增檔案到 zip 壓縮檔中

public void AddFile(string target_folder_path, string target_file_path, string newfilename = null)

Parameters

target_folder_path string

放置在壓縮檔案中的目錄的相對路徑 (目錄將自動建立)

target_file_path string

實體檔案放置位置

newfilename string

檔案新名稱,如果沒給則使用原始名稱

ParseFolder(string)

解析相對路徑,但排除 . 與 .. 兩種格式的操作符號,回傳各層目錄名稱列表

public string[] ParseFolder(string path)

Parameters

path string

相對路徑字串

Returns

string[]

依照目錄階層回傳有序的目錄陣列

RemoveTmp()

刪除暫存檔案,此函數會在 Zip() 方法完成後自動呼叫

public bool RemoveTmp()

Returns

bool

Zip()

壓縮檔案,並清除暫存檔

public bool Zip()

Returns

bool

是否壓縮成功,如果壓縮成功可以從成員 ZipDist 取得 zip 檔案路徑