[C#] FindFileSubName()

  • 494
  • 0

摘要:[C#] FindFileSubName()


      private void FindFile(string dir)
      {
         //在指定目錄下查詢文件,若符合查詢條件,將檔案寫入lsFile控制元件
         DirectoryInfo Dir = new DirectoryInfo(dir);
         try
         {
            foreach (DirectoryInfo d in Dir.GetDirectories())//查詢子目錄    
            {
               FindFile(Dir + d.ToString() + "\\");
            }
            foreach (FileInfo f in Dir.GetFiles("*.avi"))//查詢附檔名為avi的文件  
            {
               my_FileName.Add("/" + f.Name);
            }
         }
         catch (Exception ex)
         {
            //Console.WriteLine(ex.Message);
            Func.Log(logPath, logName, "frmHospitalList_FindFile()," + ex.Message, PubFunc.LogMsgType.Error);
         }
      }