HappyWeasel

C# - 파일, 폴더 존재 유무 확인 본문

Basic/ C# (.NET)

C# - 파일, 폴더 존재 유무 확인

HappyWeasel 2019. 5. 9. 12:45

파일

string _Filestr = @"파일 경로";
System.IO.FileInfo fi = new System.IO.FileInfo(_Filestr);
if (fi.Exists){
	존재 시 로직
}

else{
	없을 시 로직
}

 

폴더

string sDirPath = @"폴더 경로";
DirectoryInfo di = new DirectoryInfo(sDirPath);
if (di.Exists == false)
{
         di.Create();
}

 

 

 

'Basic > C# (.NET)' 카테고리의 다른 글

C# - Metro UI를 사용해보자  (0) 2019.05.09
C# - 폼 크기 최대로 로드하기  (0) 2019.05.09
C# - SQLite 연동하기  (0) 2019.05.09
C# - Excel 연동하기  (0) 2019.05.08
C# - delegate  (0) 2019.04.29
Comments