폴더에 파일이 있는 있는지 확인하는 방법?

데릭쉐퍼드와 여부를 확인할 수 있는 xml 파일 폴더.

DirectoryInfo di = new DirectoryInfo(ProcessingDirectory);
FileInfo[] TXTFiles = di.GetFiles("*.xml");
if (TXTFiles.Length == 0)
{
    log.Info("no files present")
}

로만스였나 확인란 폴더에 파일이 있는 가장 좋은 방법은.

나는 단순히 xml 파일이 있는지 확인해야 한다

질문에 대한 의견 (4)
해결책

이 경우, 해당 폴더에 존재하는 볼 수 있는 방법입니다 xml 파일 그렇습네다.

특정 파일 확인할지 사용할 수 있는 ['file.렉시츠 (경로)'] (http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx) 파일 처리 여부 반환되므로 부울입니다 손실됨을 http://support. '길' 존재합니다.

해설 (2)

'피라인포드렉시츠' 사용하여 속성:

DirectoryInfo di = new DirectoryInfo(ProcessingDirectory);
FileInfo[] TXTFiles = di.GetFiles("*.xml");
if (TXTFiles.Length == 0)
{
    log.Info("no files present")
}
foreach (var fi in TXTFiles)
    log.Info(fi.Exists);

['file.렉시츠'] 또는 2 방법:

string curFile = @"c:\temp\test.txt";
Console.WriteLine(File.Exists(curFile) ? "File exists." : "File does not exist.");
해설 (1)

파일이 방관하겠나 확인하기 위해 사용할 수 있습니다.

System.IO.File.Exists(path)
해설 (0)

이후 아니예 기도하였나니 있는지 확인하는 방법을 파일이 현재 폴더 실행 파일은 in (apc® 디렉토리임) 및 내려받습니다 :

if (File.Exists(Directory.GetCurrentDirectory() + @"\YourFile.txt")) {
                //do stuff
}

이 같은 것, 즉, ',' @&quot \YourFile.txt&quot 대소문자를 구분하지 않습니다 ',' 와 ',' 또는 '@&quot \YourFile.TXT&quot @&quot \YoUrFiLe.txt&quot @";;;' \yOuRfILE.tXt&quot 강조한 것은 마찬가지다.

해설 (0)

이 방법은 기존 특정 폴더에 파일을 검사할 수 있습니다.

 string curFile = @"c:\temp\test.txt";  //Your path
 Console.WriteLine(File.Exists(curFile) ? "File exists." : "File does not exist.");
해설 (0)

이 같은 개선될 수 있습니다.

if(Directory.EnumerateFileSystemEntries(ProcessingDirectory, "*.xml").ToList().Count == 0)
    log.Info("no files present")

또는:

log.Info(Directory.EnumerateFileSystemEntries(ProcessingDirectory, "*.xml").ToList().Count + " file(s) present");
해설 (0)
if (File.Exists(localUploadDirectory + "/" + fileName))
{                        
    `Your code here`
}
해설 (1)

이 날 도왔다.

bool fileExists = (System.IO.File.Exists(filePath) ? true : false);
해설 (2)

이 보케드 &gt 가져다줄래요.

file_browse_path=C:\Users\Gunjan\Desktop\New folder\100x25Barcode.prn
  String path = @"" + file_browse_path.Text;

  if (!File.Exists(path))
             {
      MessageBox.Show("File not exits. Please enter valid path for the file.");
                return;
             }
해설 (0)