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

Reading multiple files from a directory

Status
Not open for further replies.

Kori

Programmer
Oct 17, 2000
35
US
I am wanting to read Text files(*.txt) from a specific directory. I want to grab the first file read it through then grab the second file and read it through until I have read every file in that specific directory. I will know what directory these text files are in but how is done?
 
I use a for loop to do this...

dim FILETEMP as string
dim HOLDNAME as string
dim SUBX as integer


HOLDNAME = DIRECTORY & "\*.TXT"
FILETEMP = Dir(HOLDNAME)
SUBX = -1
Do While (FILETEMP <> &quot;&quot;)
SUBX = SUBX + 1
LOADGAME(SUBX) = FILETEMP
FILETEMP = Dir
Loop


DIRECTORY will be the root directory name to search from..
I.E. &quot;C:\WINDOWS&quot;

I hope this helps!
Brett Please visit my websites!
 
What is the LOADGAME()?????? And FILETEMP will be my file name each time thru the while loop?
 
The LOADGAME(SUBX) is confusing me though what is the LOADGAME array do?
 
Sorry. I forgot to explain that. LOADGAME() is a string array that holds the names of all the filenames that you retrieved in the for loop. When you are done, the LOADGAME() array will have all the names of the file that end with .txt FILETEMP is the name of the file during the loop. You can put it or use it anyway you want. I was just getting an old code example to show you.
Brett Please visit my websites!
 
Thank you it works like a charm...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top