1 year ago

#292572

test-img

dragon123

Searching Subdirectories with name as the search parameter in C#

How do we search and obtain all the subdirectories that match name as the serch parameter within a directory. For example, I have a directory in my C drive called UserInfo. There are hundreds of subdirectories (and nested subdirectories. there are more than 6 levels of nesting) in this UserInfo Directory. I wanna obtain all the subdirectories (including nested subdirectories) with names either UserLocal or UserGlobal. My aim is to get all the files inside the folders with names UserGlobal or UserLocal. Is it possible to do in one iteration or do I need two separate searches ?Directory levels-example

static void Main (string[] args)
{
    DirectoryInfo directory = new DirectoryInfo (@"C:\UserInfo");
}


c#

console

file-access

0 Answers

Your Answer

Accepted video resources