C#에서 숨김 폴더(디렉토리)를 생성하는 방법을 배워보자.
static void Main(string[] args)
{
string dirPath = "HiddenDir";
// 디렉토리가 존재하지 않으면 생성
if (!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
}
// 디렉토리 속성을 숨김으로 설정
DirectoryInfo dirInfo = new DirectoryInfo(dirPath);
dirInfo.Attributes |= FileAttributes.Hidden;
}
디렉토리 경로를 통해 DirectoryInfo 객체를 생성 후 Attributes에 Hidden을 추가해 주면 된다.
'C# > 개발' 카테고리의 다른 글
C# 비주얼스튜디오 프로젝트 이름 변경 (0) | 2024.08.13 |
---|---|
C# int to bool 변환하는 방법 (0) | 2024.04.23 |
C# 경로가 디렉토리인지 파일인지 구분하는 방법 (0) | 2024.02.02 |
C# 날짜 일수 차이 계산 (0) | 2024.01.18 |
C# 파일 이름 변경 (0) | 2024.01.13 |