From e0ccb8b10d0b63cd842ad857772b3c87f5a734d5 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 2 Aug 2021 20:40:37 -0700 Subject: [PATCH] Add drive size check (fixes #299) --- MPF/Windows/MainWindow.xaml.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MPF/Windows/MainWindow.xaml.cs b/MPF/Windows/MainWindow.xaml.cs index 7ef574d4..88bb90a3 100644 --- a/MPF/Windows/MainWindow.xaml.cs +++ b/MPF/Windows/MainWindow.xaml.cs @@ -898,6 +898,20 @@ namespace MPF.Windows } } + // Validate that at least some space exists + // TODO: Tie this to the size of the disc, type of disc, etc. + string fullPath = Path.GetFullPath(Env.OutputDirectory); + var driveInfo = new DriveInfo(Path.GetPathRoot(fullPath)); + if (driveInfo.AvailableFreeSpace < Math.Pow(2, 30)) + { + MessageBoxResult mbresult = CustomMessageBox.Show("There is less than 1gb of space left on the target drive. Are you sure you want to continue?", "Low Space", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); + if (mbresult == MessageBoxResult.No || mbresult == MessageBoxResult.Cancel || mbresult == MessageBoxResult.None) + { + LogOutput.LogLn("Dumping aborted!"); + return; + } + } + // Disable all UI elements apart from dumping button DisableAllUIElements();