Log in

View Full Version : List all pictures in a subfolders


albertkhor
10-10-2005, 09:37 AM
i doing a project. in this project i need to display all the picture inside a directory and display out.

example: i need to display all pictures inside "\My Documents\My Pictures\", but inside my pictures folder it still have subfolder, such as "family", "fren", wallpaper", and other folder.

i'm using .net compact framework, did anyone know how to code this?
i want the system search through subfolder of "my pictures" folder.

Strider
10-11-2005, 10:32 AM
this function will recursive search throught directories adding files to a listbox. All you need to do is pass in the starting directory


DirSearch("\My Documents\My Pictures\")

Sub DirSearch(ByVal searchDir As String)
Dim dir As String
Dim file As String

Try
For Each dir In Directory.GetDirectories(searchDir)
For Each file In Directory.GetFiles(dir,"*.bmp")
ListBox1.Items.Add(file)
Next
DirSearch(dir)
Next
Catch excpt As System.Exception
Debug.WriteLine(excpt.Message)
End Try
End Sub