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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List All Files On Hardrive

Status
Not open for further replies.

Calypso06

Programmer
Feb 18, 2005
15
US
I would like to create a program that gets all the files on a hardrive, or a path selected via a dir control and put it into a listbox. I can only get as far as to get all the dirs on "C:\" and one sub dir below that. Im having trouble looping after that. Thanks million for help.
 
Try something like this:

Option Explicit

Private Sub Form_Activate()
Dim x As Integer
Dim f As String
Dim myPath As String
myPath = App.Path & "\*.*" ' Change the extension that you want
f = Dir(myPath, vbNormal)
Debug.Print myPath ' Change where you want it to appear
Do While f <> ""
If f <> "." And f <> ".." Then
x = x + 1
Debug.Print x & " " & f
End If
f = Dir
Loop
End Sub

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top