C # Gets the specified type of file

C # Gets the specified type of file

  

  public static List<FileInfo> getFile(string path, string extName)
  {
    List<FileInfo> lst = new List<FileInfo>();

    the try
    {
      String [] = Directory.GetDirectories the dir (path); // folder list
      the DirectoryInfo FDIR the DirectoryInfo new new = (path);
      the FileInfo [] = fdir.GetFiles File ();
      // the FileInfo [] = the Directory.GetFiles File ( path); // file list
      !! if (file.Length = 0 || dir.Length = 0) // file in the current directory or folder is not empty
      {
        foreach (FileInfo f in file) // display all the files in the current directory
        {
          IF (. extName.ToLower () the IndexOf (f.Extension.ToLower ())> = 0)
        {
        lst.Add (F);
      }
    }
        the foreach (String D in the dir)
        {
          the getFile (D, extname); // recursion
        }
     }
    return lst;
    }catch (Exception ex){

      return lst;
    }
   }

Guess you like

Origin www.cnblogs.com/woniucode/p/11512000.html