Specify the directory to find specific types of files

. 1          ///  <Summary> 
2          /// search all files in the specified directory, the full path of the file is obtained
 . 3          ///  </ Summary> 
. 4          ///  <param name = "the dir"> Search the directory </ param> 
. 5          ///  <param name = "type"> specifies the type of file format, such as * .txt, no type is specified by * </ param> 
. 6          ///  <param name = "List"> returns the file full path </ param > 
. 7          public  static  void Director ( String the dir, String type, List < String > List)
 . 8          {
 . 9              IF (! Directory.Exists(dir)) return;
 10              the DirectoryInfo D = new new the DirectoryInfo (the dir);
 . 11              the FileInfo [] = d.GetFiles Files (type); // file 
12 is              the DirectoryInfo [] = d.GetDirectories a Directshow (); // folder 
13 is              the foreach (the FileInfo F in Files )
 14              {
 15                  list.add (f.FullName); // add to the file name list   
16              }
 17              // list file acquisition subfolder recursively traverse   
18 is              the foreach (dd the DirectoryInfo in a Directshow)
 . 19              {
 20 is                 Director(dd.FullName, type, list);
21             }
22         }
Reference: https://cloud.tencent.com/developer/article/1383919

 

Guess you like

Origin www.cnblogs.com/BKYZFSN/p/12441536.html