Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get files in the subfolders too from directory

Hi I have to get files from a specified path in the directory. This is the method I wrote but I didn't get the files from the subfolders.

Private void getfiles(){
Directoryinfo info = new Directoryinfo(configurationmanager.appsettings["Targetroot"].tostring ());
if (info.exists){
     Gvfiles.datasource = info.GetFiles();
     Gvfiles.databind();
   }
}
like image 513
Naveen Avatar asked Aug 02 '12 10:08

Naveen


1 Answers

You will want to include the SearchOption.AllDirectories.

Example:

info.GetFiles("*", SearchOption.AllDirectories);

Reference: http://msdn.microsoft.com/en-us/library/ms143327(v=vs.80).aspx

And: http://msdn.microsoft.com/en-us/library/ms143448(v=vs.80).aspx

like image 158
ickydime Avatar answered Oct 14 '22 00:10

ickydime