From 49a3c87bdfca8fcb8ff181cd0d6f58bbf0f8e984 Mon Sep 17 00:00:00 2001 From: N00MKRAD <61149547+n00mkrad@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:45:44 +0200 Subject: [PATCH] Check for writing perms in program dir --- CodeLegacy/Os/StartupChecks.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CodeLegacy/Os/StartupChecks.cs b/CodeLegacy/Os/StartupChecks.cs index 9192af3..17ae672 100644 --- a/CodeLegacy/Os/StartupChecks.cs +++ b/CodeLegacy/Os/StartupChecks.cs @@ -31,6 +31,19 @@ namespace Flowframes.Os Application.Exit(); } + // Attempt to create an empty new folder in exe dir to check if we have permissions + try + { + string testDir = Path.Combine(Paths.GetExeDir(), "test.tmp"); + Directory.CreateDirectory(Path.Combine(Paths.GetExeDir(), testDir)); + Directory.Delete(Path.Combine(Paths.GetExeDir(), testDir)); + } + catch (Exception e) + { + UiUtils.ShowMessageBox($"Flowframes does not have permission to write to its own directory!\nPlease move it to a different folder.\n\nCurrent install directory: {Paths.GetExeDir()}", UiUtils.MessageType.Error); + Application.Exit(); + } + string winVer = OsUtils.GetWindowsVer(); Logger.Log($"Running {winVer}", true);