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

loop through and get files name sin folder

Status
Not open for further replies.

angela4eva

Programmer
Apr 29, 2005
46
US
I have a folder called c:\input..i need to loop through this folder and get the anmes of all the files..note there are no sub folders in the input folder...please help.
thanks
 
At the import system.io then the command is Directory.GetFiles("c:\input")

-I hate Microsoft!
-Forever and always forward.
 
Sorry, should have said if that is all you are doing there is no reason to loop.

-I hate Microsoft!
-Forever and always forward.
 
thanks..I need to get each file anme at a time as i need to pass it as parameter to a function
thanks
 
Then this should work.

Code:
Dim fName as string

For each fName in Directory.GetFiles("c:\input") 
   Function(fName)
Loop

-I hate Microsoft!
-Forever and always forward.
 
Actually that gives you the path still if that is fine then change nothing, but if you need just the name then:

Code:
Dim fName as string

For each fName in Directory.GetFiles("c:\input") 
   Function(fName.Remove("c:\input\"))
Loop

-I hate Microsoft!
-Forever and always forward.
 
Woops thinking about the totally wrong thing. For remove it would be Remove(0, 9)

-I hate Microsoft!
-Forever and always forward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top