473,411 Members | 1,889 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,411 software developers and data experts.

Multiple Search Pattern for Directory.GetFiles

Is there a way to use multiple search patterns when calling
Directory.GetFiles.
For instance Directory.GetFiles("C:\MyFolder", "*.aspx") will return all
files with the aspx extension.
But what if I wanted all files with either an aspx OR htm extension?
Any way to get that without calling the method twice?
--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us

Nov 18 '05 #1
2 26878
Hi Alphonse,
Thanks for posting in the community! My name is Steven, and I'll be
assisting you on this issue.
From your description, you're looking for some information how to specify a
string pattern for the Diretory.GetFile method so as to implement searching
for multi extensions of files, yes ?
If there is anything I misunderstood, please feel free to let me know.
As for this problem, I've viewed the "Directory" class 's document in MSDN,
the "GetFile" method's "pattern" argument seems seems not to support the
multi extensions search pattern. The only permitted search pattern Wildcard
character are
"*" and "?". Here is the related description in MSDN:
---------------------------------------------------------
searchPattern
The search string to match against the names of files in path. The
parameter cannot end in two periods ("..") or contain two periods ("..")
followed by DirectorySeparatorChar or AltDirectorySeparatorChar, nor can it
contain any of the characters in InvalidPathChars.

---------------------------------------------------------
For more detailed description on the method, you may view the following
reference in MSDN:
http://msdn.microsoft.com/library/en...IODirectoryCla
ssGetFilesTopic2.asp?frame=true

Also, the pattern string doesn't support regular expression. And I also
tested using other separator charactors such as "," or ";" or white space
as the separator for multi-extensions , for example "*.aspx, *.htm", but
still not work. I think this maybe an acutal limit for the
Directory.GetFile method, do you think so? BTW, do you think it possible
calling the method multi-times to workaround this? Or if you have any
difficulties with this problem, would you please let me know some further
info about the problem, I'll be willing to help you.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 18 '05 #2
Thanks Steven, I had a feeling that would be the case and have worked out a
routine to call it multiple times.

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:nA**************@cpmsftngxa07.phx.gbl...
Hi Alphonse,
Thanks for posting in the community! My name is Steven, and I'll be
assisting you on this issue.
From your description, you're looking for some information how to specify a string pattern for the Diretory.GetFile method so as to implement searching for multi extensions of files, yes ?
If there is anything I misunderstood, please feel free to let me know.
As for this problem, I've viewed the "Directory" class 's document in MSDN, the "GetFile" method's "pattern" argument seems seems not to support the
multi extensions search pattern. The only permitted search pattern Wildcard character are
"*" and "?". Here is the related description in MSDN:
---------------------------------------------------------
searchPattern
The search string to match against the names of files in path. The
parameter cannot end in two periods ("..") or contain two periods ("..")
followed by DirectorySeparatorChar or AltDirectorySeparatorChar, nor can it contain any of the characters in InvalidPathChars.

---------------------------------------------------------
For more detailed description on the method, you may view the following
reference in MSDN:
http://msdn.microsoft.com/library/en...IODirectoryCla ssGetFilesTopic2.asp?frame=true

Also, the pattern string doesn't support regular expression. And I also
tested using other separator charactors such as "," or ";" or white space
as the separator for multi-extensions , for example "*.aspx, *.htm", but
still not work. I think this maybe an acutal limit for the
Directory.GetFile method, do you think so? BTW, do you think it possible
calling the method multi-times to workaround this? Or if you have any
difficulties with this problem, would you please let me know some further
info about the problem, I'll be willing to help you.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3

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

Similar topics

1
by: Les Juby | last post by:
A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script that provided great search results. It was fast,...
4
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...
2
by: ALI-R | last post by:
I am using the follwoing code to get all files which have txt as an extension but I get an error that your search pattern is not correct.it seems this fuction dosn't accept "*.txt" as search...
1
by: Prem | last post by:
Hi, I need to search a particular directory for all the files that do not have any extension and have a specific naming convension. The first 3 characters of the file name are alpha and the rest...
0
by: Hugo Mind | last post by:
Hi ng, If use this as pattern to my getfiles command --> "B7706c_2005020915253*.wav" and it returns me no files but if I use " B7706c_2005020915*.wav as the pattern then it retruns me files. ...
5
by: Dhans | last post by:
Framework version : 1.1 For a given directory (which may have subdirectories), I need to identify the number of text files (*.txt). For this I have tried recursive method to search files, it...
4
by: John Dann | last post by:
Is there a way to limit the search pattern for Directory.Getfiles to an exact number of characters. For example I want to see all the files fitting the pattern "*.abc" but excluding "*.abcd". The...
16
by: Computer geek | last post by:
Hello, I am new to VB.NET and programming in general. I have taught myself a lot of the basics with vb.net but am still quite the novice. I am working on a little application now and I need some...
2
by: princymg | last post by:
I want to search a file from server and want to copy it to the local disk. how it is done? This is working if the file is in my hard disk itself.But not when it comes to server. If i map the server...
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
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.