일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 |
30 | 31 |
Tags
- C#
- log
- windows10
- File
- coding-test
- tls
- algorithm
- Github
- Coding
- Binding
- chashtag
- ListView
- commit
- Visual Studio
- dotNET
- logging
- Microsoft
- .net
- 코딩테스트
- csharp
- convert
- windows
- IValueConverter
- git
- nullable
- programmers
- WPF
- mysql
- string
- Process
Archives
- Today
- Total
목록size (2)
CHashtag

폴더 내부의 모든 파일의 크기를 구하는 함수입니다. 단위는 byte입니다. public long GetDirectorySize(string path) { long size = 0; DirectoryInfo dirInfo = new DirectoryInfo(path); foreach (FileInfo fi in dirInfo.GetFiles("*", SearchOption.AllDirectories)) { size += fi.Length; } return size; }
C#
2021. 7. 1. 17:30

안녕하세요. 오늘은 개별 파일 크기를 구하는 방법에 대해 알아보도록 하겠습니다. 간단한 내용이니 별도의 내용 없이 코드로 보여드리겠습니다. 해당 크기는 디스크 할당 크기가 아닌 그냥 크기 임을 알려드리고 디스크 크기 구하는 방법은 다른 게시글로 정리하도록 하겠습니다. public long GetFileSize(string filePath) { long fileSize = 0; if(File.Exists(filePath)) { FileInfo info = new FileInfo(filePath); fileSize = info.Length; } return fileSize; } 감사합니다.
C#
2021. 2. 19. 21:45