Directory listing & more

D

Dave Griffiths

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
 
S

Sean

Dave Griffiths said:
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
 
D

Dave Griffiths

Thanks just what I needed.

Sean said:
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
 
D

Dave Griffiths

Sorry to say that after extensive testing I get all Extentions through not
just the valid ones.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top