我有一個包含許多子目錄的目錄。例如:如何獲取進程的具體目錄
Emp1
Acc
profile
pro1.xml
pro2.xml
data
Emp2
Acc
profile
pro1.xml
pro2.xml
data
Emp3
Acc
profile
pro1.xml
pro2.xml
data
我想寫一個foreach循環,所以我只得到駐留在配置文件夾中的文件。例如:
foreach string filename in directory.getdirectories(filepat){
//code.
}
有人可以幫我創建一個搜索模式來做到這一點嗎?
所以你想要從三個配置文件夾中的每一個的所有文件?你想用這些文件做什麼?將它們添加到列表中? – Bridge
也許遞歸方法將是一個解決方案。 – Schaliasos
如何獲取文件:http://stackoverflow.com/questions/4466756/get-files-from-multiple-directories(關於表演:http://stackoverflow.com/questions/9831641/more-efficient-method-of -getting-directory-size/9831721#9831721)以及如何獲得可執行文件路徑:http://stackoverflow.com/questions/837488/how-can-i-get-the-applications-path-in-net-in- a-console-app –