i have a list box and i want to add a folder/directory to that which is at the specified location 开发者_如何学编程i have used the code
 string path = "E:\\shruti\\MyDir";
 DirectoryItem folder = new DirectoryItem(path);
 lstBurnItems.Items.Add(folder); //add folder to listbox
but its not working fine... what should i do to get success??
Below is an example showing how to add folders within a folder to a ListBox and to add Files within a folder into a ListBox. Sorry, you weren't clear so I gave both.
        string path = @"E:\shruti\MyDir";
        string[] dirs = Directory.GetDirectories(path);
        // For folders in the directory
        foreach(string dir in dirs)
            lstBurnItems.Items.Add(dir);
        // For files in the directory
        string[] dirFiles = Directory.GetFiles(path);
        foreach (string file in dirFiles)
            lstBurnItems.Items.Add(file);
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论