I have code to find and display name of all folder in a rootfolder:
private string[] GetFolderNames(string virtualDirPath)
{
string[] Directories;
if (Directory.Exists(virtualDirPath))
{
Directories = Directory.GetDirectories(virtualDirPath);
for (int i = 0; i < Directories.Length; i++)
{
Directories[i] = MapUrl(Directories[i]);//map path to the folder
}
return Directories;
}
else
{
return null;
}
}
And code bind data to Dropdownlist:
string[] folders = GetFolderNames(RootPath);
if (folders != null)
{
dropDownListFolders.DataSource = folders;
dropDownListFolders.DataBind();
}
else
{
dropDownListFolders.Items.Insert(0, "No folders available..");
}
As the code above, the Dropdownlist display all the folder name in the Rootfolder
with path= virtualDirPath
;
But I wonder if in every child folder still has some subfolder, and in each subfolder has some more subfolder and so on more and more, so that how can I get all the name of that subfolders.
Try to make more for
loop inside the first one, but it really mess me up. And it seems that is not the good way.
I need the Dropdownlist display all the subfolder name, child of sudfolder and child of child folder... in the rootfolder. Help! I need your opinion to find a better way to to it.