Better custom personal path handling

This commit is contained in:
Jaex 2014-10-04 20:59:46 +03:00
parent 2ae48395f6
commit 16537683e5
2 changed files with 14 additions and 9 deletions

View file

@ -95,7 +95,7 @@ public static string PersonalPath
{ {
get get
{ {
if (!string.IsNullOrEmpty(CustomPersonalPath) && Directory.Exists(CustomPersonalPath)) if (!string.IsNullOrEmpty(CustomPersonalPath))
{ {
return CustomPersonalPath; return CustomPersonalPath;
} }
@ -272,6 +272,9 @@ private static void Main(string[] args)
private static void Run() private static void Run()
{ {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
IsSilentRun = CLIHelper.CheckArgs(Arguments, "silent", "s"); IsSilentRun = CLIHelper.CheckArgs(Arguments, "silent", "s");
IsSandbox = CLIHelper.CheckArgs(Arguments, "sandbox"); IsSandbox = CLIHelper.CheckArgs(Arguments, "sandbox");
@ -288,15 +291,20 @@ private static void Run()
CheckPersonalPathConfig(); 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("{0} started", Title);
DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString); DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);
DebugHelper.WriteLine("Command line: " + Environment.CommandLine); DebugHelper.WriteLine("Command line: " + Environment.CommandLine);

View file

@ -76,9 +76,6 @@ private static void Main(string[] args)
File.WriteAllText(Path.Combine(portableDir, "PersonalPath.cfg"), "ShareX", Encoding.UTF8); File.WriteAllText(Path.Combine(portableDir, "PersonalPath.cfg"), "ShareX", Encoding.UTF8);
Console.WriteLine("Created PersonalPath.cfg file."); 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")); //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 zipFilename = string.Format("ShareX-{0}.{1}.{2}-portable.zip", versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart);
string zipPath = Path.Combine(outputDir, "ShareX-portable.zip"); string zipPath = Path.Combine(outputDir, "ShareX-portable.zip");