Directory listing & more

  • Thread starter Thread starter Dave Griffiths
  • Start date Start date
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
 
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
 
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
 
Sorry to say that after extensive testing I get all Extentions through not
just the valid ones.
 
Back
Top