*foreach (string f in Directory.GetFiles(d,txtFile.Text))*
I did not understand the above line of code. Anyways if you wish to have a
alternate code, use the code below,
private void Form1_Load(object sender, EventArgs e)
{
folderBrowserDialog1.ShowDialog();
folder = folderBrowserDialog1.SelectedPath;
DirSearch(folder);
}
private void DirSearch(string sDir)
{
try
{
DirectoryInfo dir = new System.IO.DirectoryInfo(folder);
FileInfo[] fileslist = dir.GetFiles("*.*");
foreach (FileInfo f in fileslist)
{
lstFilesFound.Items.Add(f.FullName);
}
}
catch (System.Exception excpt)
{
MessageBox.Show(excpt.Message);
}
}
*Hope it will help you !!
*
On Tue, Dec 1, 2009 at 2:38 AM, Jamie Fraser <[email protected]> wrote:
> And what does debugging show you?
>
>
> On Mon, Nov 30, 2009 at 2:26 PM, neuromancer <[email protected]> wrote:
>
>> I made a form called "Form1" and dragged a "folderBrowserDialog" from
>> the toolbox. This appeared in the tray under the form. I wanted the
>> user to pick a folder, and then the filenames of the folder would
>> appear in a listbox. The listbox was also dragged onto "Form1". But
>> the following code simply does not work. The listbox never gets
>> anything in it, even though I click on a random folder in the
>> "folderBrowserDialog"
>>
>> private void Form1_Load(object sender, EventArgs e)
>> {
>> string folder;
>>
>> folderBrowserDialog1.ShowDialog();
>> folder = folderBrowserDialog1.SelectedPath;
>> DirSearch(folder);
>> }
>> void DirSearch(string sDir)
>> {
>> try
>> {
>> foreach (string d in Directory.GetDirectories(sDir))
>> {
>> foreach (string f in Directory.GetFiles(d,
>> txtFile.Text))
>> {
>> lstFilesFound.Items.Add(f);
>> }
>> DirSearch(d);
>> }
>> }
>> catch (System.Exception excpt)
>> {
>> Console.WriteLine(excpt.Message);
>> }
>> }
>>
>
>
--
Thanks & Regards,
Karthikeyan