728x90
728x170
■ FileAttributes 클래스를 사용해 디렉토리 여부를 구하는 방법을 보여준다.
▶ FileAttributes 클래스 : 디렉토리 여부 구하기 예제 (C#)
Console.WriteLine(IsDirectory("c:\\Windows"));
▶ FileAttributes 클래스 : 디렉토리 여부 구하기 (C#)
using System.IO;
#region 디렉토리 여부 구하기 - IsDirectory(source)
/// <summary>
/// 디렉토리 여부 구하기
/// </summary>
/// <param name="source">소스 문자열</param>
/// <returns>디렉토리 여부</returns>
public bool IsDirectory(string source)
{
FileAttributes attribute = File.GetAttributes(source);
if((attribute & FileAttributes.Directory) == FileAttributes.Directory)
{
return true;
}
else
{
return false;
}
}
#endregion
728x90
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] 사용자 계정 변경하기 (0) | 2018.03.24 |
---|---|
[C#/COMMON] 콘솔(Console) 닫기 버튼 비활성화 하기 (0) | 2018.03.22 |
[C#/COMMON] 디버그 모드에서 프로세스 참조 구하기 (0) | 2018.03.15 |
[C#/COMMON] ITypedList 인터페이스 : TypedCollection<T> 만들기 (0) | 2018.03.11 |
[C#/COMMON] BitConverter : ToString 정적 메소드를 사용해 바이트 배열에서 문자열 구하기 (0) | 2018.03.04 |
[C#/COMMON] 숫자 포맷 문자열 사용하기 (0) | 2018.03.04 |
[C#/COMMON] 휴지통 관리하기 (0) | 2018.03.04 |
[C#/COMMON] Environment 클래스 : Is64BitOperatingSystem 정적 속성을 사용해 64비트 운영 체제 여부 구하기 (0) | 2018.03.03 |
[C#/COMMON] Assembly 클래스 : GetExecutingAssembly 정적 메소드를 사용해 애플리케이션 실행 파일 경로 구하기 (0) | 2018.03.03 |
[C#/COMMON] 휴지통 비우기 (0) | 2018.03.01 |