473,756 Members | 3,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileSystemObjec t filter?

Hello,

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

Dim fso As New FileSystemObjec t
Dim objFolder As Folder
Dim objFile As File

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

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 10849
Do you mean you are using Scritping.FileS ystemObject ? I would use
System.IO.Direc toryInfo instead (that does what you need + it"s part of the
base .NET library)...

--
Patrice

<er**********@g mail.com> a écrit dans le message de
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Hello,

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

Dim fso As New FileSystemObjec t
Dim objFolder As Folder
Dim objFile As File

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

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**********@g mail.com> schrieb:
I'm using the Filesystemobjec t in VB.NET 1.1. Is there anyway to
filter on the files based on an extension? Something like:

Dim fso As New FileSystemObjec t
Dim objFolder As Folder
Dim objFile As File

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

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


I suggest to use 'System.IO.Dire ctory.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
3849
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 time error 76. The paths are valid. I tested them and there is a file with the extension specified. Any help is appreciated Marcelo Rizzo
5
4061
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
2120
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 directory on our database server, and they must stay there. I want to use the FileSystemObject (running on our Intranet server) to check if a photo is there, if so display it, if not
2
2179
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 folder? -- Sean.
9
3927
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', 'Scripting', 'Scripting.FileSystemObject', and a few others However, when I try to create the fso object I keep receiving an error. 'ActiveX component can't create object: 'Scripting.FileSystemObject'
2
4037
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 this possible in .NET? If so, how do I do it? I've tried:
1
17139
by: G Gerard | last post by:
Hello I am using the FileSystemObject to copy files on a computer Dim MyObject as Object
3
1860
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. When running my code compiler error coming is like User defined type not defined. before projects r running successfully with using FileSystemObject.
12
5924
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 help on this one and i tried to do the same thing with the "movefile" but it never worked as you can see the "filesystemobject" is hard to accomplish for me because this "Movefolder" event falls in this category the code i have i have used for the...
0
9869
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9708
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2665
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.