■ 디렉토리 크기 구하기

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

using System;

using System.IO;

 

#region 디렉토리 크기 구하기 - GetDirectorySize(directoryPath)

 

/// <summary>

/// 디렉토리 크기 구하기

/// </summary>

/// <param name="directoryPath">디렉토리 경로</param>

/// <returns>디렉토리 크기</returns>

public long GetDirectorySize(string directoryPath)

{

    DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);

 

    FileSystemInfo[] fileSystemInfoArray = directoryInfo.GetFileSystemInfos();

 

    long directorySize = 0L;

 

    for(int i = 0; i < fileSystemInfoArray.Length; i++)

    {

        FileInfo fileInfo = fileSystemInfoArray[i] as FileInfo;

 

        if(fileInfo != null)

        {

            directorySize += fileInfo.Length;

        }

    }

 

    return directorySize;

}

 

#endregion

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

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요