473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 10814
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marcelo Rizzo | last post by:
I am trying to get the name of a file with a specific extension (tmw) from several different directories. The problem I am having is that the program stops working on the second pass with an run...
5
by: John Dewbert | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello, I have trouble passing a folder object (from a FileSystemObject) to a sub procedure. Consider the following code: ...
3
by: Steve | last post by:
Hi all, FileSystemObject question... I'm trying to check if files exist or not, but the files are not sitting on the same server as our Intranet. Basically we have about 5000 photos in a...
2
by: Sean S - Perth, WA | last post by:
Hi all, If I create a FileSystemObject Object is it appropriate to reuse it to perform operations on different files/folders? Or should I create a new FileSystemObject Object for each file and...
9
by: kermit | last post by:
I keep seeing that you can use the FileSystemObject in either VB script, or Javascript on an aspx page. I added a refrence to the scrrun.dll I added importing namespaces for 'System.Object',...
2
by: Luis Esteban Valencia | last post by:
I'm trying to write a little VB.NET script in an ASP.NET web page that will create folders, move files, etc... pretty much everything you can expect to do using the FileSystemObject library. Is...
1
by: G Gerard | last post by:
Hello I am using the FileSystemObject to copy files on a computer Dim MyObject as Object
3
by: nagmvs | last post by:
hello I have a problem with FileSystemObject in Vb Suppose i want to declare as Dim fs As New FileSystemObject, when i type New After that i can't see FileSystemObject in derived DropDownList. ...
12
lee123
by: lee123 | last post by:
why is this so hard to do. i have alot of books that have exaples of how to do these things but when i try the exaples they never work i have a previous post on "copying files" some of the other guys...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.