Connecting Tech Pros Worldwide Forums | Help | Site Map

How to use GetFiles()

philin
Guest
 
Posts: n/a
#1: Nov 20 '05
Hi:
I am using GetFiles() method of directory class to get
some file names. I want to do know how i can setup search
pattern strings to get multiple file types. Like:

GetFiles(Path,"*.Txt") just gets txt files. I want to get
txt and doc files together. Thank a lot for your help.

philin

William Ryan
Guest
 
Posts: n/a
#2: Nov 20 '05

re: How to use GetFiles()


Dim di As DirectoryInfo

di = New DirectoryInfo("C:\")

di.GetFiles("*.txt")

"philin" <philinj@hotmail.com> wrote in message
news:028d01c3795b$62b68720$a301280a@phx.gbl...[color=blue]
> Hi:
> I am using GetFiles() method of directory class to get
> some file names. I want to do know how i can setup search
> pattern strings to get multiple file types. Like:
>
> GetFiles(Path,"*.Txt") just gets txt files. I want to get
> txt and doc files together. Thank a lot for your help.
>
> philin[/color]


Armin Zingler
Guest
 
Posts: n/a
#3: Nov 20 '05

re: How to use GetFiles()


"philin" <philinj@hotmail.com> schrieb[color=blue]
> Hi:
> I am using GetFiles() method of directory class to get
> some file names. I want to do know how i can setup search
> pattern strings to get multiple file types. Like:
>
> GetFiles(Path,"*.Txt") just gets txt files. I want to get
> txt and doc files together. Thank a lot for your help.[/color]

Either call GetFiles twice, the first time using "*.txt", the second time
"*.doc". Or call GetFiles without a filter and, afterwards, filter the files
by their extension in a loop.


--
Armin

Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#4: Nov 20 '05

re: How to use GetFiles()


Hello,

"philin" <philinj@hotmail.com> schrieb:[color=blue]
> I am using GetFiles() method of directory class to get
> some file names. I want to do know how i can setup search
> pattern strings to get multiple file types. Like:
>
> GetFiles(Path,"*.Txt") just gets txt files. I want to get
> txt and doc files together. Thank a lot for your help.[/color]

'GetFiles' doesn't accept more than one pattern. You must cann 'GetFiles'
for each pattern and "collect" the files returned by the method call.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet


Closed Thread


Similar Visual Basic .NET bytes