public sub search_wenjian() '遍歷檔案 獲得檔名稱
dim spath as string
'查詢檔案夾
spath = dir(path, vbdirectory) '查詢第乙個資料夾
do while len(spath) '迴圈到沒有資料夾為止
if left(spath, 1) <> "." then '為了防止重複查詢
if getattr(path & "\" & spath) and vbdirectory then '如果是資料夾則。。。。。。
folder_num = folder_num + 1
'folder(b) = path & spath & "\" '將目錄和資料夾名稱組合形成新的目錄,並存放到陣列中
folder_file(folder_num - 1) = spath
'folder_file_path(folder_num - 1) = path & spath & "\"
end if
end if
spath = dir '查詢下乙個資料夾
doevents '讓出控制權
loop
end sub
public sub search_file_in_folder(folder_name as string) '遍歷指定資料夾下的所有文字檔案
dim files() as string
dim a as integer
filetype = "*.*"
spath = dir(folder_name & filetype) '查詢第乙個檔案
do while len(spath) '迴圈到沒有檔案為止
a = a + 1
redim preserve files(1 to a)
files(a) = path & spath '將檔案目錄和檔名組合,並存放到陣列中
spath = dir '查詢下乙個檔案
doevents '讓出控制權
loop
end sub
VB 遍歷資料夾
如何用dir 函式來列出c下所有tmp檔案並且用文字框輸出 下面是乙個列出指定目錄下所有符合要求的檔名的函式 public function autolistfiles byval sdirname as string,byval filefilter as string as boolean on...
遍歷資料夾
function search path string filename string ball boolean false string varsearchrec tsearchrec begin if findfirst path faanyfile,searchrec 0 then begin...
資料夾遍歷
c 遍歷指定資料夾中的所有檔案 directoryinfo thefolder new directoryinfo folderfullname 遍歷一層資料夾 foreach directoryinfo nextfolder in thefolder.getdirectories 遍歷多層資料夾 ...