123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- namespace Agent.Services
- {
- public class Drive
- {
- //드라이브 명
- public string driveNm { get; set; }
- // 전체공간
- public int totalSize { get; set; }
- // 사용가능한 공간
- public int freeSize { get; set; }
- // 사용중인 공간
- public int usingSize { get; set; }
- }
- public class DriveInfoService
- {
- public List<Drive> drive
- {
- get
- {
- return _drive;
- }
- }
- private List<Drive> _drive
- {
- get
- {
- DriveInfo[] driveInfos = DriveInfo.GetDrives();
- List<Drive> listDerive = new List<Drive>();
- foreach (DriveInfo info in driveInfos)
- {
- if (info.DriveType == DriveType.Fixed)
- {
- // 전체공간
- int totalSize = Convert.ToInt32(info.TotalSize / Math.Pow(1024, 3));
- // 사용가능한 공간
- int freeSize = Convert.ToInt32(info.AvailableFreeSpace / Math.Pow(1024, 3));
- // 사용중인 공간
- int usingSize = (totalSize - freeSize);
- listDerive.Add(new Drive() { driveNm = info.Name, totalSize = totalSize, freeSize = freeSize, usingSize = usingSize });
- }
- }
- return listDerive;
- }
- }
- public List<Drive> TotalDrive
- {
- get
- {
- return _TotalDrive;
- }
- }
- private List<Drive> _TotalDrive
- {
- get
- {
- DriveInfo[] driveInfos = DriveInfo.GetDrives();
- List<Drive> listDerive = new List<Drive>();
- int totalSize = 0;
- int usingSize = 0;
- int freeSize = 0;
- foreach (DriveInfo info in driveInfos)
- {
- if (info.DriveType == DriveType.Fixed)
- {
- // 전체 용량을 계산합니다.
- totalSize += Convert.ToInt32(info.TotalSize / Math.Pow(1024, 3));
- // 전체 사용가능한 공간
- freeSize += Convert.ToInt32(info.AvailableFreeSpace / Math.Pow(1024, 3));
- // 사용중인 공간
- usingSize += (totalSize - freeSize);
- }
- }
- listDerive.Add(new Drive() { driveNm = "ToTal", totalSize = totalSize, freeSize = freeSize, usingSize = usingSize });
- return listDerive;
- }
- }
- }
- }
|