This step-by-step article shows how to recursively search subdirectories for files in a C# Windows Forms application. A search string is specified so that you can find files.

Directory recursion is a common IO task. The FileSystemObject makes this job easy for Component Object Model applications. Now, these activities have become even easier in .NET. Similar to the FileSystemObject, the classes in the System.IO namespace provides an object-oriented way to access files and directories.

Can you call Directory.GetFiles() with multiple filters?

Note that with .NET 4.0, you can replace Directory.GetFiles with Directory.EnumerateFiles,, which will avoid the memory

5/5 - (4 votes)