473,800 Members | 2,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

filesystem.getf iles question

I'm using filesystem.getf iles - and so far it's working correctly *however*
I'd sure like to be able to pass it, as the last parameter, the extensions
(plural) for which I'm looking.

I assumed that "*.exe, *.dll" for example would work but it seems to not
like that syntax. Would someone correct my misinformation and give me a
way to pass more than a single pattern to that last parameter??

Thanks //al
Feb 13 '06 #1
11 12507
"al jones" <al**********@s hotmail.com> schrieb
I'm using filesystem.getf iles - and so far it's working correctly
*however* I'd sure like to be able to pass it, as the last
parameter, the extensions (plural) for which I'm looking.

I assumed that "*.exe, *.dll" for example would work but it seems to
not like that syntax. Would someone correct my misinformation and
give me a way to pass more than a single pattern to that last
parameter??

It is not possible to pass multiple extensions. Get all files and filter
them by extension in a loop.

I don't see the relation to the VB.Net language. Maybe one of the Framework
groups is the better place to ask:

microsoft.publi c.dotnet.framew ork.*

You'll benefit from the none-VB'ers, too.
Armin

Feb 13 '06 #2
CMM
If you're using VB2005,
My.Computer.Fil eSystem.GetFile s(...)
Allows you to specify multiple patterns.

--
-C. Moya
www.cmoya.com
Feb 13 '06 #3
CMM
"Armin Zingler" <az*******@free net.de> wrote in message
microsoft.publi c.dotnet.framew ork.*
You'll benefit from the none-VB'ers, too.


Sorta ironic you say this... considering the feature he seeks AFAIK is only
available in VB (2005) via
My.Computer.Fil eSystem.GetFile s(...)

--
-C. Moya
www.cmoya.com
Feb 13 '06 #4
CMM
On the other hand, if you're using VB2003, then you can't use
My.Computer.Fil eSystem.GetFile s().

In which case you can either:

1) Get all the files (*.*) and loop through them yourself recursively using
VB's Like operator (very handly little known comparison operator).

For Each file As String in filesAry
For Each pattern As String in patternsAry
If File.GetFileNam e(file) Like pattern Then
'do something
End If
Next pattern
Next file

2) Call GetFiles multiple times each with a different pattern. I would
actually think #1 above is the faster option.

--
-C. Moya
www.cmoya.com
"CMM" <cm*@nospam.com > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
If you're using VB2005,
My.Computer.Fil eSystem.GetFile s(...)
Allows you to specify multiple patterns.

--
-C. Moya
www.cmoya.com

Feb 13 '06 #5
On Mon, 13 Feb 2006 16:40:44 -0500, CMM wrote:
If you're using VB2005,
My.Computer.Fil eSystem.GetFile s(...)
Allows you to specify multiple patterns.


I got a chuckle out of your response to Armin - I assumed that getfiles
would be available across the family of languages but you're right I *am*
using vb2005.

I must be being really dense, though, can you explain how to specify those
multiple patterns? The tooltip associated with getfiles says that this
item is a ParamArray wildcards() as string. I've tried "*.exe;*.dl l" which
returned nothing and thinking that This should be an array
{"*.exe","*.dll "} which the ide complains about ...

Another response to a similar questions suggests making two passes one for
each extension - which is doable, but the time this takes on a large
directory is long to begin with, doubling or tripling it would be
prohibitive. Suggestions?

And thanks to both of you //al
Feb 14 '06 #6
CMM
A "paramarray " means you can specify parameters *inline* for infinity pretty
much
MyProc(param1,p aram2,param3,pa ram4, ...) You can also pass them as a
singular array if you want. This is how you use the getfiles function:

....

Dim files As ObjectModel.Rea dOnlyCollection (Of String) = _
My.Computer.Fil eSystem.GetFile s("C:\Temp",
FileIO.SearchOp tion.SearchAllS ubDirectories, "*.exe", "*.dll")

or

Dim files2 As ObjectModel.Rea dOnlyCollection (Of String) = _
My.Computer.Fil eSystem.GetFile s("C:\Temp",
FileIO.SearchOp tion.SearchAllS ubDirectories, New String() {"*.exe",
"*.dll"})
P.S.
ObjectModel.Rea donlyCollection is in the System.Collecti ons namespace.

--
-C. Moya
www.cmoya.com
"al jones" <al**********@s hotmail.com> wrote in message
news:19******** *************** ******@40tude.n et...
On Mon, 13 Feb 2006 16:40:44 -0500, CMM wrote:
If you're using VB2005,
My.Computer.Fil eSystem.GetFile s(...)
Allows you to specify multiple patterns.


I got a chuckle out of your response to Armin - I assumed that getfiles
would be available across the family of languages but you're right I *am*
using vb2005.

I must be being really dense, though, can you explain how to specify those
multiple patterns? The tooltip associated with getfiles says that this
item is a ParamArray wildcards() as string. I've tried "*.exe;*.dl l"
which
returned nothing and thinking that This should be an array
{"*.exe","*.dll "} which the ide complains about ...

Another response to a similar questions suggests making two passes one for
each extension - which is doable, but the time this takes on a large
directory is long to begin with, doubling or tripling it would be
prohibitive. Suggestions?

And thanks to both of you //al

Feb 14 '06 #7
I think the VB.net developers had to go to school to learn how to make
things as convoluted as possible.

GalenS

"CMM" <cm*@nospam.com > wrote in message
news:er******** ******@TK2MSFTN GP15.phx.gbl...
A "paramarray " means you can specify parameters *inline* for infinity
pretty much
MyProc(param1,p aram2,param3,pa ram4, ...) You can also pass them as a
singular array if you want. This is how you use the getfiles function:

...

Dim files As ObjectModel.Rea dOnlyCollection (Of String) = _
My.Computer.Fil eSystem.GetFile s("C:\Temp",
FileIO.SearchOp tion.SearchAllS ubDirectories, "*.exe", "*.dll")

or

Dim files2 As ObjectModel.Rea dOnlyCollection (Of String) = _
My.Computer.Fil eSystem.GetFile s("C:\Temp",
FileIO.SearchOp tion.SearchAllS ubDirectories, New String() {"*.exe",
"*.dll"})
P.S.
ObjectModel.Rea donlyCollection is in the System.Collecti ons namespace.

--
-C. Moya
www.cmoya.com
"al jones" <al**********@s hotmail.com> wrote in message
news:19******** *************** ******@40tude.n et...
On Mon, 13 Feb 2006 16:40:44 -0500, CMM wrote:
If you're using VB2005,
My.Computer.Fil eSystem.GetFile s(...)
Allows you to specify multiple patterns.


I got a chuckle out of your response to Armin - I assumed that getfiles
would be available across the family of languages but you're right I *am*
using vb2005.

I must be being really dense, though, can you explain how to specify
those
multiple patterns? The tooltip associated with getfiles says that this
item is a ParamArray wildcards() as string. I've tried "*.exe;*.dl l"
which
returned nothing and thinking that This should be an array
{"*.exe","*.dll "} which the ide complains about ...

Another response to a similar questions suggests making two passes one
for
each extension - which is doable, but the time this takes on a large
directory is long to begin with, doubling or tripling it would be
prohibitive. Suggestions?

And thanks to both of you //al


Feb 14 '06 #8
CMM
I don't see how.
Doesn't get much simpler than usage of that function... and intellisense
guides you the whole way... though I guess it does look wordy.

--
-C. Moya
www.cmoya.com
Feb 14 '06 #9
"CMM" <cm*@nospam.com > schrieb
On the other hand, if you're using VB2003, then you can't use
My.Computer.Fil eSystem.GetFile s().

In which case you can either:

1) Get all the files (*.*) and loop through them yourself
recursively using VB's Like operator (very handly little known
comparison operator).

For Each file As String in filesAry
For Each pattern As String in patternsAry
If File.GetFileNam e(file) Like pattern Then


I'd prefer

select case io.path.getexte nsion.tolower
case ".exe", ".dll" 'or without dot (never know by heart)
msgbox "good file"
case
msgbox "bad file"
end seelct

:)
Armin
Feb 14 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1895
by: Lucas Fletcher | last post by:
Hi All, I've searched the web for an article explaining the many tradeoffs between storing your XML in a database vs the filesystem but I haven't really found anything of note. This is the little I've come up with: FileSystem Pros:
4
7113
by: Ben Fidge | last post by:
Hi What is the most efficient way to gather a list of files under a given folder recursively with the ability to specify exclusion file masks? For example, say I wanted to get a list of all files under \Program Files and it's subdirectories that meet the following criteria:
13
2640
by: Tom Scales | last post by:
OK, I admit, I am not a VB.NET expert and am still learning, but have run into an annoying problem. I'm writing a program that has to search the file system and therefore processes large numbers of directories and files. I've figured out DirectoryInfo (it's pretty simple), but when I invoke DirectoryInfo.GetFiles (or even DirectoryInfo.GetDirectories), it can take forever. Some of the directories have thousands of files in them. So, my...
4
1379
by: Yves | last post by:
Hello, I have a little question. I want to make a small app that counts all the files located in a specific directory (chosen via a FolderBrowserDialog by a user). The question is: is there a method (of something else) that can retrieve all the files (in that specific directory) and subdirectories (and in possible subdirectories of the subdirectories). So I mean every single file starting with the given folder and not only the files in...
1
1767
by: Starbuck | last post by:
Hi When the routine below is run it gets to the line - Dim fileEntries As String() = Directory.GetFiles(tString) and then freezes, there is no errors etc, the program just stops responding. The path is correct and does exist and there is a test file in there Any thoughts please? Private Sub InboxTimer_Tick(ByVal sender As System.Object, ByVal e As
0
1533
by: Tamir Khason | last post by:
According guidlines of ASP.NET security with medium trust level I should able to use file system IO with my virtual directory, but actual recieve error 500 (not appears with full trust level) Following two examples. "My virtual directory/Some directory/Some other directory" within an application in "My virtual directory" I have to get FileVersionInfo of files from "Some other directory" string dPath = "Some directory"; ArrayList al =...
0
1389
by: graphicsxp | last post by:
Hi, I need to find recursively all the files which have extension .mdb so I did that: files = My.Computer.FileSystem.GetFiles("C:\Databases", FileIO.SearchOption.SearchAllSubDirectories, "*.mdb") Now I want to exclude the file which contain the strings "_Backup" or "basket" in the filename (and still filtering on *.mdb). I suppose I should use regular expressions, but I can't figure out what the
4
5669
by: | last post by:
Hi all, I want to create a method that does the following: 1) Programmatically instantiate a new XmlDataSource control 2) For each file in a named directory, make a "FileSystemItem" element 3) On each FileSystemItem Element, make two child nodes, one with the file name, one with the file size. ie. <filesystemitems> <filesystemitem>
3
2553
by: Michael Jackson | last post by:
In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFiles(path) to get all the files in the directory. However, I'm getting an error regarding "Illegal character in Path", even though I can copy, etc the file using the Windows XP explorer. I can trap the error, but then this traps the entire GetFiles() function, not just the one bad file. Is there a way to just trap for the one bad file and continue on?
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10504
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10251
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,...
1
7576
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
6811
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
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.