list file from folder

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have to list files that are in a folder,the files have four different
extensions, How can I show all the files I need in a listbox then allow the
user to select 1 or 2 files so it can do some database uploading of them
files? The folder also has files in it that I don't need such as .doc, .txt
and .xls, extensions, I need everything else but those files
 
You can get list of all files using Directory or DirecotyInfo classes. Both
types support GetFiles method where you can provide search pathern.

I think Directory class could be more convenient because its methods are
static.
 
CSharpguy said:
I have to list files that are in a folder,the files have four different
extensions, How can I show all the files I need in a listbox then allow
the
user to select 1 or 2 files so it can do some database uploading of them
files? The folder also has files in it that I don't need such as .doc,
.txt
and .xls, extensions, I need everything else but those files

Check out 'System.IO.Directory.GetFiles' and 'System.IO.Path.*'.
 
I can list the files fine, but how can I exclude the files I don't need? I
don't want to see .tmp, .doc, .xls, .txt files, so how can i exclude those
files?
 
CSharpguy said:
I can list the files fine, but how can I exclude the files I don't need? I
don't want to see .tmp, .doc, .xls, .txt files, so how can i exclude those
files?

Either make multiple calls to 'Directory.GetFiles' with different patterns
or determine all files in the folder and filter them yourself using VB's
'Like' operator or regular expressions
('System.Text.RegularExpressions.Regex.IsMatch').
 
Back
Top