Freek's Blog

SQL en .NET vraagstukken en oplossingen die ik zoal tegenkom
posts - 199, comments - 123, trackbacks - 2, articles - 7

My Links

News

Google analytics script: Locations of visitors to this page

Article Categories

Archives

Post Categories

Image Galleries

Algemene links

MSDN

vb links

C#: Collect quickly directory names and loop through them

Posted on Wednesday, May 12, 2010 12:32 PM

//collect directory names and put them in an array
string
[] mapnaam = System.IO.Directory.GetDirectories(@"C:\");

//loop through the array
foreach
(string map in mapnaam)
{
//for each file found in the directory with the extension 'txt'
foreach
(string filename in System.IO.Directory.GetFiles(map, "*.txt", System.IO.SearchOption.TopDirectoryOnly))
{
do something...
}
}

Post Comment

Title  
Name  
Url
Comment   

ATTENTION: the code you need to copy is CaSe SeNsItIvE and is required to prevent spam.
Enter the code you see: