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!

How to send to a table every file in a directory 1

Status
Not open for further replies.

VictorFRodriguez

Programmer
Jan 20, 2001
51
DO
I would like to insert into a table every file in a directory. With GETFILE() I can see them. But, What code should I use to append them to a table?
Victor F. Rodriguez
 
Hi Victor

Try the ADIR function.

SET DEFA TO C:\MyDirectory
gnDbcnumber = ADIR(gaDatabase, '*.*') && Create array

FOR nCount = 1 TO gnDbcnumber && Loop for number of files
lcFile = gaDatabase(nCount,1)
SELECT myTable
APPEND BLANK
REPLACE myTable.filename with lcFile
ENDFOR

You can play with the code. I usually prefer insert over append but append is nice for demo purposes.




Jim Osieczonek
Delta Business Group, LLC
 
Thanks for your prompt answer. I am trying to put it into practice and have encountered another inconvenience. I am using VFP5 and tried to locate the DEFAULT DIRECTORY WITH
cDefault = GETDIR()
But when I
SET DEFAULT TO cDefault
an invalid error occurs.
The default directory is very hard to find and it is written with long file names... like this
C:\Documents and settings\all users\Documents\My faxes\Sent Faxes
Any solution...?
 
This should work:

SET DEFAULT TO (cDefault)

You need the () because of the spaces in the filepath.


Jim Osieczonek
Delta Business Group, LLC
 
Thanks a lot for your help !! It worked exactly as I wanted.
Victor F. Rodriguez
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top