For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > March 2004 > Re: A simple GetDirectories question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: A simple GetDirectories question
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


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com