dupont2406
asked on
Import all files in a directory in Visual Basic
I have a program that imports data from a text file. I am able to import the data from the specific file by specifying the exact path. I would like to know how to import each file in the directory regardless of the name of the file. After the file has been imported I would like it deleted.
Directory to import from is c:\importfolder
Thank You
Directory to import from is c:\importfolder
Thank You
Sorry, for:
strFile = Dir$("c:\yourfolder\")
Read:
strFile = Dir$("c:\importfolder\")
strFile = Dir$("c:\yourfolder\")
Read:
strFile = Dir$("c:\importfolder\")
Apologies again,
Replace:
strFile = Dir$("c:\yourfolder\")
With:
strFile = Dir$("c:\importfolder\*.*" )
(It's 3:28am local time, btw!)
Replace:
strFile = Dir$("c:\yourfolder\")
With:
strFile = Dir$("c:\importfolder\*.*"
(It's 3:28am local time, btw!)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That works
Thank You
Thank You
You're welcome.
Thanks for closing the question so promptly.
BFN,
fp.
Thanks for closing the question so promptly.
BFN,
fp.
Dim strFile As String
strFile = Dir$("c:\yourfolder\")
While Len(Trim$(strFile)) > 0
' Import your file here based on the filename being in the string variable strFile
' YOUR CODE HERE
' After processing, delete the specific file & see if there are any more...
Kill strFile
strFile = Dir$()
Wend
BFN,
fp.