728x90
반응형
728x170
[TestProject]
▶ Program.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using TestCommon;
namespace TestProject
{
/// <summary>
/// 프로그램
/// </summary>
class Program
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Private
#region 프로그램 실행하기 - Main()
/// <summary>
/// 프로그램 실행하기
/// </summary>
static void Main()
{
string sourceDirectoryPath = "c:\\temp";
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
DriveInfo driveInfo = new DriveInfo(sourceDirectoryPath.Substring(0, 1));
NTFSReader reader = new NTFSReader(driveInfo, RetrieveMode.ALL);
IEnumerable<INode> nodeEnumerable = reader.GetNodeList(sourceDirectoryPath);
int directoryCount = 0;
int fileCount = 0;
ulong directorySize = 0UL;
foreach(INode node in nodeEnumerable)
{
if((node.AttributeType & NodeAttributeType.DIRECTORY) != 0)
{
directoryCount++;
}
else
{
fileCount++;
directorySize += node.Size;
}
}
Console.WriteLine("소스 디렉토리 경로 : {0}" , sourceDirectoryPath);
Console.WriteLine(" 하위 디렉토리 카운트 : {0}" , directoryCount - 1 );
Console.WriteLine(" 파일 카운트 : {0}" , fileCount );
Console.WriteLine(" 디렉토리 크기 : {0:N0} 바이트", directorySize );
}
#endregion
}
}
※ 윈도우 10에서는 비주얼 스튜디오를 관리자 권한으로 실행해야 한다.
※ GPT 포맷의 첫번째 파티션의 경우 읽지 못하고, 지정 디렉토리의 크기가 실제와 차이가 있으나 NTFS MFT 사용 코드에 의미를 두었다.
728x90
반응형
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] DirectoryInfo 클래스 : GetDirectories 메소드를 사용해 디렉토리 크기 구하기 (0) | 2018.10.01 |
---|---|
[C#/COMMON] WebClient 클래스 : HTTPS 파일 다운로드 하기 (0) | 2018.09.22 |
[C#/COMMON] DirectoryInfo 클래스 : EnumerateDirectories 메소드를 사용해 디렉토리 크기 구하기 (0) | 2018.09.21 |
[C#/COMMON] 파일 경로 축약하기 (0) | 2018.09.17 |
[C#/COMMON] 파일 크기 문자열 구하기 (0) | 2018.09.17 |
[C#/COMMON] DirectoryInfo 클래스 : EnumerateDirectories 메소드를 사용해 디렉토리 크기 구하기 (0) | 2018.09.13 |
[C#/COMMON] DirectoryInfo 클래스 : EnumerateFiles 메소드를 사용해 디렉토리 크기 구하기 (0) | 2018.09.13 |
[C#/COMMON] FSO를 사용해 디렉토리 크기 구하기 (0) | 2018.09.13 |
[C#/COMMON] 우리나라 전통 색상 코드 (0) | 2018.09.08 |
[C#/COMMON] Convert 클래스 : ChangeType 정적 메소드를 사용해 지정 타입으로 변환하기 (0) | 2018.09.03 |
댓글을 달아 주세요