internal static FileSystem[] GetDrives() { List <FileSystem> allDrives = new List <FileSystem>(); UnixDriveInfo[] drives = UnixDriveInfo.GetDrives(); foreach (UnixDriveInfo udi in drives) { // We exclude some irrelevant (pseudo)filesystems /*if(udi.DriveFormat == "proc" || udi.DriveFormat == "sysfs" || udi.DriveFormat == "debugfs" || udi.DriveFormat == "devpts" || udi.DriveFormat == "procfs") || continue;*/ FileSystem sd = new FileSystem(); sd.MountPoint = udi.Name; sd.OriginalMountPoint = udi.Name; //sd.Name = udi.VolumeLabel; sd.Size = udi.TotalSize; sd.AvailableFreeSpace = udi.AvailableFreeSpace; sd.Path = udi.VolumeLabel; //sd.Path = udi.Name; sd.DriveFormat = udi.DriveFormat; //sd.DriveType = (DriveType)udi.DriveType; try{ sd.SnapshotType = FilesystemManager.GetDriveSnapshotType(sd.MountPoint); } catch {} allDrives.Add(sd); } return(allDrives.ToArray()); }
// if running on Mono #if __MonoCS__ public static bool DriveFreeBytes(string folderName, out ulong freespace, out ulong total) { freespace = 0; total = 0; UnixDriveInfo[] drives = UnixDriveInfo.GetDrives(); int idx = -1, count = -1; for (int i = 0; i < drives.Length; ++i) { if (folderName.StartsWith(drives[i].Name) && drives[i].Name.Length > count) { count = drives[i].Name.Length; idx = i; } } // Drive for path is: drives[idx].Name freespace = (ulong)drives[idx].AvailableFreeSpace; total = (ulong)drives[idx].TotalSize; return(true); }