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

How to read the name of files in a folders?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Can someone help me plz?

I have a folder with images i have to read all the files name and fill a combo box with the names of the files.

Thanks.
 

Use the FileSystemObject, it works like a champ.

----

Dim oFSO As Scripting.FileSystemObject

Private Sub Form_Load()
Set oFSO = New Scripting.FileSystemObject
oneFolder App.Path & "\files"
End Sub

Private Function oneFolder(ByVal sDir As String) As String
Dim oDir As Scripting.Folder
Dim oFile As Scripting.File

Set oDir = oFSO.GetFolder(sDir)

For Each oFile In oDir.Files
Debug.Print oFile.Path
oFile.Name = "_" & oFile.Name
Next
End Function

----

Hope this does what you need.

-Matt
 
To clarify,
That is a peice of code I used to change names of files.
Just change the

oFile.Name = "_" & oFile.Name

portion of it to something that will hold your file names.

-Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top