class Lesson
{
public Lesson()
{
// 해당 디렉토리 내부 정보 가져오기
string[] infos = GetDirInfos(@"C:\Windows");
foreach (string info in infos)
{
System.Console.WriteLine(info);
}
}
// 해당 디렉토리의 하위 디렉토리, 파일 정보 가져오기
private string[] GetDirInfos(string dirPath)
{
System.IO.DirectoryInfo infos = new System.IO.DirectoryInfo(dirPath);
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
foreach (var dir in infos.GetDirectories())
{
list.Add(dir.FullName);
}
foreach (var dir in infos.GetFiles())
{
list.Add(dir.FullName);
}
return list.ToArray();
}
}
- 내용이 간단해서 설명 생략
2023.10.07 - [C#] - [C#] 폴더 (디렉토리) 생성
2023.10.07 - [C#] - [C#] 폴더 (디렉토리) 존재 여부 확인
2023.10.07 - [C#] - [C#] 파일 생성
2023.10.07 - [C#] - [C#] 폴더 (디렉토리) 이동, 이름 변경
2023.10.07 - [C#] - [C#] 파일 이동, 이름 변경
2023.10.07 - [C#] - [C#] 디렉토리 삭제
'C#' 카테고리의 다른 글
[C#] 파일 이동, 이름 변경 (0) | 2023.10.07 |
---|---|
[C#] 폴더 (디렉토리) 이동, 이름 변경 (0) | 2023.10.07 |
[C#] 파일 생성 (0) | 2023.10.07 |
[C#] 폴더 (디렉토리) 존재 여부 확인 (0) | 2023.10.07 |
[C#] 폴더 (디렉토리) 생성 (0) | 2023.10.07 |