CODE: [Copy to clipboard]
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("c:\")
Set oFile = oFSO.OpenTextFile("a.txt",2,True)
GetFileName oFolder
oFile.Close
Set oFile = Nothing
Set oFSO = Nothing
Sub GetFileName(oFolder)
For Each tmpFile In oFolder.Files
If LCase(Right(tmpFile.Name,4)) = ".txt" Then
oFile.WriteLine tmpFile.Path
End If
Next
For Each tmpFolder In oFolder.SubFolders
GetFileName(tmpFolder)
Next
End Sub
其他一些组件也能完成类似的功能(Shell.Application等等),不过个人认为这上面两种方法无疑简单许多.