Skip to content

Commit

Permalink
Added the possibility to get the drive with the highest available fre…
Browse files Browse the repository at this point in the history
…e space (#40)
  • Loading branch information
lpeyr committed Dec 3, 2022
1 parent 0394927 commit db76cf3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions PeyrSharp.Env/FileSys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,19 @@ public static DriveInfo DriveWithLowestFreeSpace
return drives.OrderBy(x => x.TotalFreeSpace).First(); // Return the drive with the lowest free space
}
}

/// <summary>
/// Gets the drive with the higest free space available.
/// </summary>
/// <returns>A <see cref="DriveInfo"/> value, which contains the information of the drive.</returns>
public static DriveInfo DriveWithHighestFreeSpace
{
get
{
var drives = DriveInfo.GetDrives(); // Get all drives
drives = drives.Where(x => x.DriveType != DriveType.CDRom).ToArray(); // Remove CD-ROM
return drives.OrderByDescending(x => x.TotalFreeSpace).First(); // Return the drive with the highest free space
}
}
}
}

0 comments on commit db76cf3

Please sign in to comment.