From d7ee3cee6dec56b93d5657baa3a1724bc60c0196 Mon Sep 17 00:00:00 2001 From: Rampastring Date: Sat, 12 Sep 2020 00:57:57 +0300 Subject: [PATCH] Fix crash when saving a map without overriding an existing file --- CnCTDRAMapEditor/MainForm.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CnCTDRAMapEditor/MainForm.cs b/CnCTDRAMapEditor/MainForm.cs index 9ad7478..c2f8669 100644 --- a/CnCTDRAMapEditor/MainForm.cs +++ b/CnCTDRAMapEditor/MainForm.cs @@ -858,7 +858,8 @@ namespace MobiusEditor return false; } - if (new FileInfo(saveFilename).Length > Globals.MaxMapSize) + var fileInfo = new FileInfo(saveFilename); + if (fileInfo.Exists && fileInfo.Length > Globals.MaxMapSize) { MessageBox.Show(string.Format("Map file exceeds the maximum size of {0} bytes.", Globals.MaxMapSize), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }