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

Directory listing & more

Hi All

Using vb.net 2005

I am listing a directory into a ListView Control using the following code,
it works no problems.

Is it possible to list the files of more than one extention say .jpg .gif
and .png at the same time or must I use the routine 3 times once for each
extention to get all the file for the 3 extentions

Dim di As New DirectoryInfo(path)
Dim f As FileInfo
Dim x As Integer = 0

For Each f In di.GetFiles("*.jpg")
lv.Items.Add(f.Name)
lv.Items(x).SubItems.Add(f.Extension)
x += 1
Next

Thanks in advance.
DaveG

Apr 11 '07 #1
3 1397

"Dave Griffiths" <da*********@hotmail.com.nospamwrote in message
news:6_********************@telenor.com...
Hi All

Using vb.net 2005

I am listing a directory into a ListView Control using the following code,
it works no problems.

Is it possible to list the files of more than one extention say .jpg .gif
and .png at the same time or must I use the routine 3 times once for each
extention to get all the file for the 3 extentions

Dim di As New DirectoryInfo(path)
Dim f As FileInfo
Dim x As Integer = 0

For Each f In di.GetFiles("*.jpg")
lv.Items.Add(f.Name)
lv.Items(x).SubItems.Add(f.Extension)
x += 1
Next

Thanks in advance.
DaveG
Could you use something like:

For Each f In di.GetFiles("*.*")
If (Instr(1, "Valid: jpg gif tif ", f.Extension) 0)
lv.Items.Add(f.Name)
lv.Items(x).SubItems.Add(f.Extension)
x += 1
End If
Next

Apr 11 '07 #2
Thanks just what I needed.

"Sean" <sean.anderson@[nospam]oakleafgroup.bizwrote in message
news:11***************@kestrel.skynet.co.uk...
>
"Dave Griffiths" <da*********@hotmail.com.nospamwrote in message
news:6_********************@telenor.com...
>Hi All

Using vb.net 2005

I am listing a directory into a ListView Control using the following
code, it works no problems.

Is it possible to list the files of more than one extention say .jpg .gif
and .png at the same time or must I use the routine 3 times once for each
extention to get all the file for the 3 extentions

Dim di As New DirectoryInfo(path)
Dim f As FileInfo
Dim x As Integer = 0

For Each f In di.GetFiles("*.jpg")
lv.Items.Add(f.Name)
lv.Items(x).SubItems.Add(f.Extension)
x += 1
Next

Thanks in advance.
DaveG

Could you use something like:

For Each f In di.GetFiles("*.*")
If (Instr(1, "Valid: jpg gif tif ", f.Extension) 0)
lv.Items.Add(f.Name)
lv.Items(x).SubItems.Add(f.Extension)
x += 1
End If
Next
Apr 11 '07 #3
Sorry to say that after extensive testing I get all Extentions through not
just the valid ones.

"Dave Griffiths" <da*********@hotmail.com.nospamwrote in message
news:nu********************@telenor.com...
Thanks just what I needed.

"Sean" <sean.anderson@[nospam]oakleafgroup.bizwrote in message
news:11***************@kestrel.skynet.co.uk...
>>
"Dave Griffiths" <da*********@hotmail.com.nospamwrote in message
news:6_********************@telenor.com...
>>Hi All

Using vb.net 2005

I am listing a directory into a ListView Control using the following
code, it works no problems.

Is it possible to list the files of more than one extention say .jpg
.gif and .png at the same time or must I use the routine 3 times once
for each extention to get all the file for the 3 extentions

Dim di As New DirectoryInfo(path)
Dim f As FileInfo
Dim x As Integer = 0

For Each f In di.GetFiles("*.jpg")
lv.Items.Add(f.Name)
lv.Items(x).SubItems.Add(f.Extension)
x += 1
Next

Thanks in advance.
DaveG

Could you use something like:

For Each f In di.GetFiles("*.*")
If (Instr(1, "Valid: jpg gif tif ", f.Extension) 0)
lv.Items.Add(f.Name)
lv.Items(x).SubItems.Add(f.Extension)
x += 1
End If
Next
Apr 11 '07 #4

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

Similar topics

2
by: Dean | last post by:
Hi I've got a question relating to using Javascript on an Intranet. I have a directory with a list of files in the format week36.xls, week37.xls and I want to write a script that will scan...
19
by: SU News Server | last post by:
I've struggled with this for quite a while and I'm am just not sure what is going on. I have the following code import os def buildList( directory='/Users/mkonrad' ) dirs = listing =...
2
by: Tom | last post by:
I need to get a directory listing through http. If I put the directory path in the browser address bar such as http://somewebpage.com/subdir I get the listing of the directory. Of course this is...
5
by: Michael C | last post by:
....on a remote machine? Thanks, Michael C.
8
by: gil | last post by:
Is it possible to prevent a browser from listing the entire contents of a folder? The site, is hosted on my ISP with the following layout- site/ "user name from ISP" pagefile (dir)...
8
by: dougawells | last post by:
Hi - I'm hoping for help with the auto-generation of a hyperlinked listing of all files in a directory. The server I use does not auto-generate this. So, when someone comes to this directory and...
7
by: epikto | last post by:
I have a mapped share that I am trying to get a listing of all the files that it contains. I use the following code to access the contents String files = Directory.GetFiles(path); I can then...
4
by: techusky | last post by:
I have a *very* simple script written that displays the directory listing of the current working directory, but I am having some difficulty when I try to change folders. Basically, I have my $dir...
1
by: Steve | last post by:
My site is hosted on a Godaddy reseller site. Godaddy only allows the use of Curl to access remote sites. What is the method for listing a directory after connecting to the site with Curl? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.