Click to See Complete Forum and Search --> : Get filenames from "multiselect" openFileDialog


efkefk
June 22nd, 2006, 07:05 AM
Hello,
I am trying to catch the Filenames string from a multiselection of an openFileDialog dialog control. But I do not know how to get the number of selected files. So when I do this:
for (i = 0; i < 1000; i++)
{
filename[i] = openFileDialog.FileNames[i].ToString();
}
This of course fails when there is no more existing openFileDialog.FileNames[i].

So I need to know the number of selected files. Does the openFileDialog give it ? Otherwise how to proceed ?

klintan
June 22nd, 2006, 07:26 AM
Try


string filename[] = openFileDialog.FileNames;


To get count, use


int noOfSelectedFiles=openFileDialog.FileNames.Length;


or do the same on the filename[] array.

efkefk
June 22nd, 2006, 08:30 AM
Thank you.
It works.