|
取得指定目錄下的子目錄及文件
Sub CurrentDirectoryFile(MyPath As String, Optional MyName As String = vbNullString)
MyPath = "D:\"
If MyName = vbNullString Then
MyName = Dir(MyPath, vbDirectory) 'Directory
Else
MyName = Dir(MyPath & MyName, vbNormal) 'Files
End If
Do While MyName <> ""
If MyName <> "." And MyName <> ".." Then
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Debug.Print "Folder:" & MyName
Else
Debug.Print "File:" & MyName
End If
End If
MyName = Dir
Loop
End Sub
|
|