/// <summary> /// Update disk capacity /// </summary> private void RefreshDiskCapacity() { DriveInfo[] drives = DriveInfo.GetDrives(); foreach (DriveInfo di in drives) { // Unusable disk if (di.IsReady == false) { continue; } FlowLayoutPanel flp = (di.DriveType == DriveType.Fixed) ? uiFlp_Local : uiFlp_Share; foreach (Control c in flp.Controls) { if (!(c is DiskCtl)) { continue; } DiskCtl ctl = c as DiskCtl; if (ctl.DISK_NAME == di.Name) { ctl.FREE_SIZE = di.AvailableFreeSpace; ctl.SetDiskCapacity(); } } } }
/// <summary> /// Create disk /// </summary> private void SetDisk() { DriveInfo[] drives = DriveInfo.GetDrives(); foreach (DriveInfo di in drives) { // Unusable disk if (di.IsReady == false) { continue; } DiskCtl ctl = new DiskCtl { DISK_TYPE = di.DriveType, DISK_NAME = di.Name, TOTAL_SIZE = di.TotalSize, FREE_SIZE = di.AvailableFreeSpace }; FlowLayoutPanel flp = (ctl.DISK_TYPE == DriveType.Fixed) ? uiFlp_Local : uiFlp_Share; flp.Controls.Add(ctl); } }