469,903 Members | 2,151 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

FileSystemObject filter?

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

Jan 30 '06 #1
2 10248
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)...

--
Patrice

<er**********@gmail.com> a écrit dans le message de
news:11**********************@z14g2000cwz.googlegr oups.com...
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

Jan 30 '06 #2
<er**********@gmail.com> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Marcelo Rizzo | last post: by
5 posts views Thread by John Dewbert | last post: by
2 posts views Thread by Sean S - Perth, WA | last post: by
2 posts views Thread by Luis Esteban Valencia | last post: by
1 post views Thread by G Gerard | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.