基於資料夾目錄生成CHM電子書

2021-09-08 07:31:08 字數 1940 閱讀 7080

昨天因為時間的原因,就草草的寫了個比較簡單的方法,呼叫hha.dll來編譯chm檔案,昨天晚上回去,將這個方法整理到chmhelper.dll中了,具體的**如下:

chmdocument.cs檔案

新增編譯的過載方法

//////

使用hha.dll進行編譯

///

///

///

public

bool

compile(

string

file)

關於hha.dll中的 **

delegate

string

getinfo(

string

log);

[dllimport(

"hha.dll")]

static

extern

bool

hha_compilehhp(

string

hhp, getinfo pro, getinfo fi, 

intflag);

public

string

getinfo1(

string

log)  

新的建立hhp的方法

//////

建立hhp檔案

///

///htm檔名

private

void

createhhp()

這個是測試的資料夾目錄:

程式的介面如下:很簡單的乙個介面,選擇根目錄,編譯(使用hha.dll)

這個是生成的chm電子書,基於資料夾目錄的

**:遍歷整個目錄,生成父節點、子節點

private

void

getfiles(

string

filepath, chmnode node)

}directoryinfo chldfolders 

=folder.getdirectories();

foreach

(directoryinfo chldfolder 

inchldfolders)}

編譯按鈕,在這裡設定跟節點

private

void

btncomplie_click(

object

sender, eventargs e)

chmdocument document 

=new

chmdocument();

document.filename ="

made by alexis";

document.title ="

alexis";

//設定根目錄的名字

//根節點

chmnode root 

=new

chmnode();

root.name 

=this

.txtpath.text.substring(

this

.txtpath.text.lastindexof('\\

') +1

);document.nodes.add(root);

getfiles(

this

.txtpath.text, root);

//編譯

document.compile("a

");}

資料夾文件目錄生成

先解決第乙個內容 檔案在 這個有幾種辦法,我覺得最快速 形象和直觀的辦法是使用dos語句中的tree命令來實現文件生成,具體步驟如下 win r 開啟執行欄,輸入 cmd 輸入 tree 檢視tree命令的用法,可以看到非常詳細的說明 c users lucky tree 以圖形顯示驅動器或路徑的資...

遍歷資料夾 建立目錄

searchsubdir lpcstr lpszfolderpath else while findnextfilea hfile,wfd createdirectory in lpctstr lpszdirname advance over it.if p skip until we hit th...

Python建立目錄資料夾

python對檔案的操作還算是方便的,只需要包含os模組進來,使用相關函式即可實現目錄的建立。1 os.path.exists path 判斷乙個目錄是否存在 2 os.makedirs path 多層建立目錄 3 os.mkdir path 建立目錄 直接上 def mkdir path 引入模組...