From 16537683e58ca9733c2f32c7ecb740761b6e81fa Mon Sep 17 00:00:00 2001 From: Jaex Date: Sat, 4 Oct 2014 20:59:46 +0300 Subject: [PATCH] Better custom personal path handling --- ShareX/Program.cs | 20 ++++++++++++++------ ShareXPortable/Program.cs | 3 --- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ShareX/Program.cs b/ShareX/Program.cs index c2c059bd2..bb34b53e7 100644 --- a/ShareX/Program.cs +++ b/ShareX/Program.cs @@ -95,7 +95,7 @@ public static string PersonalPath { get { - if (!string.IsNullOrEmpty(CustomPersonalPath) && Directory.Exists(CustomPersonalPath)) + if (!string.IsNullOrEmpty(CustomPersonalPath)) { return CustomPersonalPath; } @@ -272,6 +272,9 @@ private static void Main(string[] args) private static void Run() { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + IsSilentRun = CLIHelper.CheckArgs(Arguments, "silent", "s"); IsSandbox = CLIHelper.CheckArgs(Arguments, "sandbox"); @@ -288,15 +291,20 @@ private static void Run() CheckPersonalPathConfig(); } - if (!string.IsNullOrEmpty(PersonalPath) && !Directory.Exists(PersonalPath)) + if (!Directory.Exists(PersonalPath)) { - Directory.CreateDirectory(PersonalPath); + try + { + Directory.CreateDirectory(PersonalPath); + } + catch (Exception e) + { + MessageBox.Show("Unable to create folder: \"" + PersonalPath + "\"\r\n\r\n" + e.ToString(), "ShareX - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + CustomPersonalPath = ""; + } } } - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - DebugHelper.WriteLine("{0} started", Title); DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString); DebugHelper.WriteLine("Command line: " + Environment.CommandLine); diff --git a/ShareXPortable/Program.cs b/ShareXPortable/Program.cs index 407a0184b..bff003ba2 100644 --- a/ShareXPortable/Program.cs +++ b/ShareXPortable/Program.cs @@ -76,9 +76,6 @@ private static void Main(string[] args) File.WriteAllText(Path.Combine(portableDir, "PersonalPath.cfg"), "ShareX", Encoding.UTF8); Console.WriteLine("Created PersonalPath.cfg file."); - Directory.CreateDirectory(Path.Combine(portableDir, "ShareX")); - Console.WriteLine("Created ShareX folder."); - //FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(releaseDir, "ShareX.exe")); //string zipFilename = string.Format("ShareX-{0}.{1}.{2}-portable.zip", versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart); string zipPath = Path.Combine(outputDir, "ShareX-portable.zip");