Aug 19, 2009

Get Files From SubFolder Recursively

Get files from directory (including all subdirectories)

If you want to search also in subfolders use parameter SearchOption.A­llDirectories.

string[] filePaths = Directory.GetFiles(@"c:\test\", "*.bmp",
SearchOption.AllDirectories);

returns:
"c:\test\test.BMP"
"c:\test\test2\test2.BMP"

for Folder:

string[] folders = System.IO.Directory.GetDirectories(@"C:\test\","*", System.IO.SearchOption.AllDirectories);

Bookmark and Share

No comments:

Post a Comment