■ 디렉토리를 삭제하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
using System.IO; #region 디렉토리 삭제하기 - DeleteDirectory(directoryPath) /// <summary> /// 디렉토리 삭제하기 /// </summary> /// <param name="directoryPath">디렉토리 경로</param> public void DeleteDirectory(string directoryPath) { foreach(string filePath in Directory.GetFiles(directoryPath)) { File.SetAttributes(filePath, FileAttributes.Normal); File.Delete(filePath); } foreach(string subsidaryDirectory in Directory.GetDirectories(directoryPath)) { DeleteDirectory(subsidaryDirectory); } Directory.Delete(directoryPath, false); } #endregion |