Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

directory searching 1

Status
Not open for further replies.

simanek

Programmer
Jan 19, 2001
137
US
Hi,

I want to create a script that i can put in scheduler that will traverse a directory and list all of the files. Unfortunately, I know VERY little about VB so I was hoping someone could point me in the right direction or to a couple of online resources. I'm very new to visual basic so if there is a better way than vb to solve my problem please let me know. Thanks much. Mike
~~~~
simanek@uiuc.edu
"It's a Swingline!"
~~~~
 
Here is a sample...
Create a new form and put a command buuton on it (called Command1), add the reference "Microsoft Scripting Runtime" to your list of references (Project->References...)
Add this code...

Private Sub Command1_Click()
Dim fso As New FileSystemObject
Dim myFolders As Folders, myFiles As Files
Dim aFolder As Folder, aFile As File

'looping for all the folders.
Set myFolders = fso.GetFolder("C:\myFolder").SubFolders
For Each aFolder In myFolders
MsgBox aFolder.Name
Next aFolder

Set myFiles = fso.GetFolder("C:\myFolder").Files
For Each aFile In myFiles
MsgBox aFile.Name
Next aFile

Set fso = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top