how do i get a list of all the files in a directory?
Printable View
how do i get a list of all the files in a directory?
set a reference to Microsoft Scripting Runtime and add a listbox to the form then stick this code in somewhere:
Nice and quick! Read up on the FSO to find out more of the cool stuf it does. (its loads better than the DIR() function).Code:Dim MyFSO As New FileSystemObject
Dim MyFolder As Folder
Dim MyFile As File
Set MyFolder = MyFSO.GetFolder("C:\Windows\Desktop")
For Each MyFile In MyFolder.Files
List1.AddItem MyFile.Name
Next MyFile
wossname's reply looks good
perhaps he can tell me how to set a reference to Microsoft Scripting Runtime
cheers
yep,
click on the Project menu and then click Refernces (theres no keyboard shortcut that I know of) you will find a whole bunch of useful DLL's and bits, find the one named "Microsoft Scripting Runtime" and check the box next to it.
the first thing you will notice is some new variable types become available.
Hows that?
cheers wossname
looks very useful