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

How to use fso.GetFile to get more files??

Status
Not open for further replies.

LordDuzy

Programmer
Feb 12, 2004
22
PL
This is the problem
When i get a file, i have to place the full name
Like:
Set myfile = fso.GetFile("C:\Myfolder\file.dat")

Is there a possibility to "Get" all the files in one dir
without knowing the file names?? or just one after a nother useing "For each next"?
thx in advance
 

The following code will loop through a directory and delete files older than 10 days for a directory in
m_strReportLoc. Hope this helps you a bit.




Dim fsoPurge As FileSystemObject
Dim fsoFolder As Folder
Dim fsoFile As File

Set fsoPurge = New FileSystemObject
Set fsoFolder = fsoPurge.GetFolder(m_strReportLoc)

For Each fsoFile In fsoFolder.Files
If DateDiff("d", fsoFile.DateCreated, Now) > 10 Then
fsoFile.Delete True
End If
Next

Set fsoFile = Nothing
Set fsoFolder = Nothing
Set fsoPurge = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top