FileSystemObject filter?

E

eric.goforth

Hello,

I'm using the Filesystemobject in VB.NET 1.1. Is there anyway to
filter on the files based on an extension? Something like:

Dim fso As New FileSystemObject
Dim objFolder As Folder
Dim objFile As File

'Work with the root first
objFolder = fso.GetFolder(strWWWRoot)

For Each objFile In objFolder.Files("*.txt")

Next

I've search on the web and in the archives and can't find anything. I
can test for the file extension on each file, but this seems
ridiculously awkward. My recollection with some of the VB6 filesystem
controls was that you could put a filter in them.

Thanks,
Eric
 
P

Patrice

Do you mean you are using Scritping.FileSystemObject ? I would use
System.IO.DirectoryInfo instead (that does what you need + it"s part of the
base .NET library)...
 
H

Herfried K. Wagner [MVP]

I'm using the Filesystemobject in VB.NET 1.1. Is there anyway to
filter on the files based on an extension? Something like:

Dim fso As New FileSystemObject
Dim objFolder As Folder
Dim objFile As File

'Work with the root first
objFolder = fso.GetFolder(strWWWRoot)

For Each objFile In objFolder.Files("*.txt")

I suggest to use 'System.IO.Directory.GetFiles(<path>, <pattern>)' instead
of the FSO.
 

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