Using dir() to get a list of files and directories
instead of using the api and having to deal with nulls and UDT's and stuff, y not just use dir(), i have included 2 functions that return string arrays which contain all the files or directorys in the folder u specify. enjoy :)
AI
สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
ซอร์สโค้ด
Public Function GetFolderList(Path As String) As String()
Dim Dirs() As String, Cnt As Integer
Dim I As String
I = Dir$(Path, vbDirectory)
Do While I <> ""
If (GetAttr(Path & I) And vbDirectory) = vbDirectory Then
If Trim$(I) = "." Or Trim$(I) = ".." Then GoTo DontAddItem
If Cnt = 0 Then ReDim Dirs(0) Else ReDim Preserve Dirs(0 To Cnt + 1)
Dirs(Cnt) = Path & Trim$(I)
Cnt = Cnt + 1
End If
DontAddItem:
I = Dir$()
Loop
GetFolderList = Dirs()
End Function
Public Function GetFileList(Path As String, Match As String) As String()
Dim Files() As String, Cnt As Integer
Dim I As String
I = Dir$(Path & Match)
Do While I <> ""
If Cnt = 0 Then ReDim Files(0) Else ReDim Preserve Files(0 To Cnt + 1)
Files(Cnt) = Path & Trim$(I)
Cnt = Cnt + 1
I = Dir$()
Loop
GetFileList = Files()
End Function
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine