■ 디렉토리 삭제하기

----------------------------------------------------------------------------------------------------

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

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요