mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-30 10:19:51 +08:00
25 lines
602 B
C#
25 lines
602 B
C#
using System.IO;
|
|
|
|
namespace MicaSetup.Helper;
|
|
|
|
public static class DriveInfoHelper
|
|
{
|
|
public static long GetAvailableFreeSpace(string path)
|
|
{
|
|
string driveName = Path.GetPathRoot(path);
|
|
DriveInfo driveInfo = new(driveName);
|
|
long availableSpace = driveInfo.AvailableFreeSpace;
|
|
|
|
return availableSpace;
|
|
}
|
|
|
|
public static string ToFreeSpaceString(this long freeSpace)
|
|
{
|
|
if (freeSpace >= 1073741824)
|
|
{
|
|
return $"{(double)freeSpace / 1073741824:0.##}GB";
|
|
}
|
|
return $"{(double)freeSpace / 1048576:0.##}MB";
|
|
}
|
|
}
|