[VB6] 怎樣可以取得本機上所有TXT檔案的完整路徑?
怎樣可以取得本機上所有TXT檔案的完整路徑?
假如檔案是這樣的:
C:
|-A.TXT
|-B.TXT
|-FOLDER1
|-C.TXT
|-FOLDER2
|-FOLDER3
|-FILE.TXT
D:
|-DTXT.TXT
結果應是:
"C:\\A.TXT"
"C:\\B.TXT"
"C:\\FOLDER1\\C.TXT"
"C:\\FOLDER2\\FOLDER3\\FILE.TXT"
"D:\\DTXT.TXT"
請間該怎樣做?
TO ALL :
PLEASE USE CHINESE !
2 個解答
- LiangLv 61 十年前最愛解答
You may do it like this:
圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/...
Depends on the number of files in your drives, it may takes several minutes to run.
Please click here to download the source code.
2007-06-09 16:07:39 補充:
感謝garlic2010為我作了補充,我不選擇“late binding”的做法,是因為要「優化」程式的執行速度,我現在用中文在此列出在VB 6加入「Microsoft Scripting Runtime參考」之步驟:1. 選「專案」→ 選「參考」加入至顯示「參考對話盒」2. 按「瀏覽」以開啟「加入參考對話盒」3. 選“scrrun . dll”檔案,按「確定」關閉「加入參考對話盒」(“Microsoft Scripting Runtime”在「參考對話盒」的「可用的參考」清單中列出) 4. 按「確定」關閉「參考對話盒」
2007-06-09 16:09:01 補充:
請注意:因為程式要做大量讀取外部儲存裝置的操作,執行需時,請耐心等候。
資料來源: 原創 - garlic2010Lv 71 十年前
雁妮 gives a very neat program.
I have just one thing to add. To use FileSystemObject, you have to add
C:\Winsows\System32\Scrrun.dll to Project Reference or use late binding
Dim fs as Object
Set fs = CreateObject("Scripting.FileSystemObject")