list of files

M

mike

can anyone help?

I recall, when previously looking around MVPS sites,
seeing something which would give a list and details of
files in a specified drive and now that i want to do that
i cant find it again! Can anyone remember who did
this/where it was?

tia

mike
 
M

Mike

I'll assume you aren't refering to Windows Explorer?

To retrieve information in any folder, you can use
something like this bit of code:

With Application.FileSearch
.NewSearch
.LookIn = SomePath '"C:\"
or "C:\MyPath\MyFolder\Etc\"
.SearchSubFolders = True 'or False
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles 'See help for more
types
.Filename = "*"
.Execute

'This bit puts the filename, length and count into an
array that is used later on in my routine. Note that
FoundFiles(i) includes the complete path, not just the
filename. You could replace this piece with direct writes
to a worksheet.

ReDim CArray(.FoundFiles.Count, 3)
For i = 1 To .FoundFiles.Count
CArray(i - 1, 0) = .FoundFiles(i)
CArray(i - 1, 1) = FileLen(.FoundFiles(i))
CArray(i - 1, 2) = FileDateTime(.FoundFiles(i))
On Error GoTo 0
Next

End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top