Could not find a part of the path ...folder name not concatenating

0

I am assembling a routine which will recursively navigate through a folder tree...but it falls over on the second level. I have it wired to a double click which populates a listbox with the names of folders. At root and first levels no problem, then when I go to another double click the part of the path that I've just navigated is missing. Here's the function as it stands:

          public void button6_Click(object sender, EventArgs e)
    {
        Fill_ListBox(Lb_Folders, @"Y:\", "*");
     }
    private void Fill_ListBox(ListBox Lb_Folders, string Folder, string 
             FileType)
    {
        var currentfolder = (string)Lb_Folders.SelectedItem;
        DirectoryInfo dinfo = new DirectoryInfo(currentfolder+Folder);

        DirectoryInfo [] dirs = dinfo.GetDirectories(FileType);

        foreach(DirectoryInfo flder in dirs)
        {
            Lb_Folders.Items.Add(flder.Name);
        }
    }

I thought adding the variable 'currentfolder' would resolve this issue but apparently not. Any advice?

 The error message returned is: System.IO.DirectoryNotFoundException occurred HResult=0x80070003  Message=Could not find a part of the path 'Y:\AR 
 Certification'. Source=mscorlib
navigation
folder
asked on Stack Overflow Dec 1, 2017 by Mark Wild

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0