Home All Groups Group Topic Archive Search About

FileSystemObject filter?

Author
30 Jan 2006 3:20 PM
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

Author
30 Jan 2006 3:25 PM
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)...

--
Patrice

<eric.gofo***@gmail.com> a écrit dans le message de
Show quoteHide quote
news:1138634439.219175.173440@z14g2000cwz.googlegroups.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
>
Author
30 Jan 2006 5:02 PM
Herfried K. Wagner [MVP]
<eric.gofo***@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/>