문제

해당 파일의 존재 여부를 확인하기 위해 파일 경로가 포함된 문자열을 테스트하고 싶습니다(예: -e Perl에서 테스트하거나 os.path.exists() Python) C#에서.

도움이 되었습니까?

해결책

사용:

File.Exists(path)

MSDN: http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx

편집하다:System.IO에서

다른 팁

시스템.IO.파일:

using System.IO;

if (File.Exists(path)) 
{
    Console.WriteLine("file exists");
} 

System.IO.File.Exists(경로)

msdn

전체 경로를 입력으로 제공하십시오.상대 경로를 피하세요.

 return File.Exists(FinalPath);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top