How to get list of all folders in a Dropdown List

Step 1. create a website+add a Default.aspx page

Step 2. Add A dropdownlist.

Step 3. On page load write the code after adding using System.IO; namespace.

foreach (var folder in Directory.GetDirectories(@"E:\"))
{
    DropDownList1.Items.Add(folder.ToString().Replace(@"E:\",""));
}

Run your application to get list of all folders.

Ebook Download
View all
Learn
View all