views:

20

answers:

1

Hello there!

I have a visual c++ windows form application (empty) made on visual studio 2008

I would like to add a button so users can browse a folder.

after they select the folder I would like to "scan" that folder and list all the images (JPG, PNG and GIF) in my windows form application.

can anyone provide me with the steps required ?

Thank you

A: 

I am not sure if there is any automatic way to scan image files but since you have only 3 extensions, you could try the following per extension,

string[] imageList = Directory.GetFiles(path, "*.jpg");

where path is the folder you browse to using the browse folder dialog (NOT the browse file dialog).

It returns a string of all the files in the directory along with their full paths. Optionally you can trim of the path using a simple .Split('\') command.

I'm not sure if the string[] will work in C++ as the syntax seems to want the hat symbol, as seen below.

array<String^>^imageList

Here is the link for the getfiles method.

nEm