| Anoop C M 2004-03-31, 12:44 pm |
| Hi,
This is a good recursive function that've used and is available in msdn.
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);
}
}
HTH
Anoop
"Ing. Rajesh Kumar" <iambad@post.cz> wrote in message
news:e4ybBdeCEHA.1688@TK2MSFTNGP12.phx.gbl...
Hi everybody
I am populating a dropdown list with directory names from a given directory.
But how can i get the names for all the sub sub sub directories ?
What i want is :
Let's say i have a directory which contains DIR_A, DIR_A contains DIR_B,
DIR_B contains DIR_C.
I want to populate dropdown list as :
<asp:ListItem Value="DIR_A" Text="DIR_A"/>
<asp:ListItem Value="DIR_A/DIR_B" Text="DIR_B"/>
<asp:ListItem Value="DIR_A/DIR_B/DIR_C" Text="DIR_C"/>
Following code does not give the result i want
Dim dirInfo as New DirectoryInfo(Server.MapPath(path))
ddl_1.DataSource = dirInfo.GetDirectories()
Thanks in advance
Raja
|