Dim hFile As Long
Dim WFD As WIN32_FIND_DATA
hFile = FindFirstFile("c:\*.*", WFD)
If hFile <> INVALID_HANDLE_VALUE Then
Do DoEvents
List1.AddItem "c:\" & Left$(WFD.cFileName, InStr(WFD.cFileName, vbNullChar) - 1)
Loop While FindNextFile(hFile, WFD)
Call FindClose(hFile)
End If
请问这样怎么扫描子文件夹? 能否给修改下。。
Dim WFD As WIN32_FIND_DATA
hFile = FindFirstFile("c:\*.*", WFD)
If hFile <> INVALID_HANDLE_VALUE Then
Do DoEvents
List1.AddItem "c:\" & Left$(WFD.cFileName, InStr(WFD.cFileName, vbNullChar) - 1)
Loop While FindNextFile(hFile, WFD)
Call FindClose(hFile)
End If
请问这样怎么扫描子文件夹? 能否给修改下。。
Dim fh as long
Dim ret As Long
Dim s As String
Dim tp As String
Dim t as WIN32_FIND_DATA tp = np & "\*.*"
fh = FindFirstFile(tp, t)
If fh = -1 Then
ff = 0
Exit Function
End If
Do
DoEvents
If Left(t.cFileName, 1) <> "." Then
t.cFileName = ""
ret = FindNextFile(fh, t)
If ret = 0 Then Exit Function
If Left(t.cFileName, 1) <> "." Then
'put your own code here
p = np & "\" & Left(t.cFileName, InStr(t.cFileName, Chr(0)) - 1)
ff (p)
End If
End If
t.cFileName = ""
Loop Until fh = -1End Function
你肿么连个递归都没有
Dim fh As Long
Dim ret As Long
Dim p As String
Dim tp As String
Dim t As WIN32_FIND_DATA tp = np & "\*.*"
fh = FindFirstFile(tp, t)
If fh = -1 Then
ff = 0
Exit Function
End If
Do
DoEvents
If Left(t.cFileName, 1) <> "." Then
t.cFileName = ""
ret = FindNextFile(fh, t)
If ret = 0 Then Exit Function
If Left(t.cFileName, 1) <> "." Then
'Debug.Print t.cFileName
'put your own code
p = np & "\" & Left(t.cFileName, InStr(t.cFileName, Chr(0)) - 1)
ff (p)
End If
End If
t.cFileName = ""
Loop Until fh = -1End Function
'然后读文件d:\allfilesinc.txt的内容