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

looping to find a specific file

Status
Not open for further replies.

amberH

Programmer
Jun 10, 2002
36
CA
You guys are awesome!!
The database I'm building is going great.
This question will be easy for yous.
Every day there is a random number of files created and stored in a folder. What is the best way to go through this folder, and get all files?
I already have it finding the correct filename, but I'm not sure about which would be the best way to say:
"Do until there are no more new files"
"......"
"Loop"

Specifically, I'm looking for the syntax of the "Do" line.

THANKS!
amber
 
You could use:


Dim strFile As String

strFile = Dir("c:\test\test\*.*")

Do While strFile <> &quot;&quot;
'stuff to do here
strFile = Dir
Loop


Dir will return the filename if it is found in the path specified. In this case we are returning multiple so we can return the next file (if exists) by calling the Dir function again without any parameters. There may be a need to check for folders if there is a possibility of them. Or you can modify the Dir statement to reflect a particular file type if that is an option.

I hope this is what you were looking for.

jitter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top