473,387 Members | 2,436 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,387 software developers and data experts.

How to use GetFiles

yxq
Hi,
I only can get one file type using GetFiles function,

GetFiles(path, "*.txt")

But if i want to get two or more file types, how to do?

Thanks
Nov 20 '05 #1
5 1696

Dim str() as String

str = GetFiles(path, "*.*")

For i = 0 to str.Length -1

If Path.GetExtension(str(i)) = ".txt" or Path.GetExtension(str(i)) =
".doc" then
'--- Do whatever
End if

Next
yxq wrote:
Hi,
I only can get one file type using GetFiles function,

GetFiles(path, "*.txt")

But if i want to get two or more file types, how to do?

Thanks

Nov 20 '05 #2
"yxq" <ga***@163.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I only can get one file type using GetFiles function,
GetFiles(path, "*.txt")
But if i want to get two or more file types, how to do?


Imports System.IO
.. . .
For Each eFile As String In Directory.GetFiles(path, "*.*")
Select Case Path.GetExtension(eFile).ToLower()
Case ".doc", ".txt"
' Do Something
End Select
Next

HTH,
Phill W.
Nov 20 '05 #3
"yxq" <ga***@163.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I only can get one file type using GetFiles function,
GetFiles(path, "*.txt")
But if i want to get two or more file types, how to do?


Imports System.IO
.. . .
For Each eFile As String In Directory.GetFiles(path, "*.*")
Select Case Path.GetExtension(eFile).ToLower()
Case ".doc", ".txt"
' Do Something
End Select
Next

HTH,
Phill W.
Nov 20 '05 #4
yxq
Thank you

"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> дÈëÓʼþ
news:c4**********@yarrow.open.ac.uk...
"yxq" <ga***@163.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I only can get one file type using GetFiles function,
GetFiles(path, "*.txt")
But if i want to get two or more file types, how to do?


Imports System.IO
. . .
For Each eFile As String In Directory.GetFiles(path, "*.*")
Select Case Path.GetExtension(eFile).ToLower()
Case ".doc", ".txt"
' Do Something
End Select
Next

HTH,
Phill W.

Nov 20 '05 #5
yxq
Thank you

"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> дÈëÓʼþ
news:c4**********@yarrow.open.ac.uk...
"yxq" <ga***@163.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I only can get one file type using GetFiles function,
GetFiles(path, "*.txt")
But if i want to get two or more file types, how to do?


Imports System.IO
. . .
For Each eFile As String In Directory.GetFiles(path, "*.*")
Select Case Path.GetExtension(eFile).ToLower()
Case ".doc", ".txt"
' Do Something
End Select
Next

HTH,
Phill W.

Nov 20 '05 #6

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

Similar topics

2
by: Demetri | last post by:
Using the GetFiles method of the DirectoryInfo instance one can pass in a search pattern of string type. For example: DirectoryInfo di = new DirectoryInfo("C:\temp"); FileInfo fi =...
3
by: S. Han | last post by:
I'm using Directory.GetFiles to enumerate files in a directory. The problem is if you have to enumerate all files + subdirectories recursively, it takes too much memory, and it fails. Is there...
2
by: John Smith | last post by:
Hello all: I am trying to search for more than one extension in a directory at the same time with the following code: string files = Directory.GetFiles(sDir, "*.doc*.dot"); However, this...
3
by: philin | last post by:
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")...
11
by: al jones | last post by:
I'm using filesystem.getfiles - 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...
1
by: Hawk | last post by:
I was writing my own wildcard compare algorithm and making a custom GetFiles routine when I came across what I think is a bug in .net's own GetFiles. My routine was coming up with different...
13
by: Lance | last post by:
Hi All, I'm working on a program that requires searching multiple drives for multiple file types and cataloging them based on certain geospatial attributes. All together, there are hundreds of...
1
by: jobs | last post by:
Say I only have a single file I want to get information on. How can I adapt this code? Dim dr As DataRow Dim fi As FileInfo Dim dir As New DirectoryInfo(filename) Dim dt As New DataTable...
3
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...
0
by: tshad | last post by:
I am trying to do multiple Directory.GetFiles and append the results to one array that I will process. I tried this: string strFiles; strFiles = Directory.GetFiles(SemaSettings.InputFilePath,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.