using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LB_SmartVisionCommon { public class DiskInfoHelper { public static double GetFreeSpaceGB(string driveName) { try { DriveInfo drive = new DriveInfo(driveName); return drive.IsReady ? Math.Round((double)drive.AvailableFreeSpace / (1024 * 1024 * 1024), 2) : -1; } catch { return -1; } } public static Dictionary GetDiskDetails(string driveName) { var result = new Dictionary(); try { DriveInfo drive = new DriveInfo(driveName); if (drive.IsReady) { result["DriveName"] = drive.Name; result["TotalSizeGB"] = Math.Round((double)drive.TotalSize / (1024 * 1024 * 1024), 2); result["FreeSpaceGB"] = Math.Round((double)drive.AvailableFreeSpace / (1024 * 1024 * 1024), 2); result["DriveFormat"] = drive.DriveFormat; result["DriveType"] = drive.DriveType.ToString(); } } catch (Exception ex) { result["Error"] = ex.Message; } return result; } } }