I'm using this library to get the amount of free disk space:
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)][return: MarshalAs(UnmanagedType.Bool)]private static extern bool GetDiskFreeSpaceEx(string lpDirectoryName, out ulong lpFreeBytesAvailable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes);I use it in the method as:
var result = GetDiskFreeSpaceEx(desiredInstallLocation, out var freeBytesAvailable, out var totalNumberOfBytes, out var totalNumberOfFreeBytes);Then the condition comes to the play:
if (gameSize > (int)freeBytesAvailable){ MessageBox.Show($"There is not enough disk space!\nYou need to free at least {ConvertBytesToMegabytes(gameSize - (int)freeBytesAvailable)} MB.", "Not enough space on a disk", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); return false;}Here is the record from the debugging:
Why is the condiiton passed?

