Update personal path before debug helper init otherwise in portable build logger will save to incorrect folder

This commit is contained in:
Jaex 2015-11-22 03:31:48 +02:00
parent b6959520a9
commit c101742d2c
2 changed files with 39 additions and 33 deletions

View file

@ -93,7 +93,7 @@ private void WriteLineInternal(string message)
{
if (!string.IsNullOrEmpty(LogFilePath))
{
File.AppendAllText(LogFilePath, message, Encoding.UTF8);
File.AppendAllText(LogFilePath, message + Environment.NewLine, Encoding.UTF8);
}
}
catch (Exception e)

View file

@ -243,8 +243,6 @@ public static string ScreenshotsFolder
[STAThread]
private static void Main(string[] args)
{
DebugHelper.Init(LogsFilePath);
Application.ThreadException += Application_ThreadException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
@ -259,6 +257,10 @@ private static void Main(string[] args)
if (CheckAdminTasks()) return; // If ShareX opened just for be able to execute task as Admin
UpdatePersonalPath();
DebugHelper.Init(LogsFilePath);
IsMultiInstance = CLI.IsCommandExist("multi", "m");
if (IsMultiInstance || ApplicationInstanceManager.CreateSingleInstance(SingleInstanceCallback, args))
@ -281,36 +283,6 @@ private static void Run()
Application.SetCompatibleTextRenderingDefault(false);
IsSilentRun = CLI.IsCommandExist("silent", "s");
IsSandbox = CLI.IsCommandExist("sandbox");
if (!IsSandbox)
{
IsPortable = CLI.IsCommandExist("portable", "p");
if (IsPortable)
{
CustomPersonalPath = PortablePersonalFolder;
}
else
{
IsPortable = File.Exists(PortableCheckFilePath);
CheckPersonalPathConfig();
}
if (!Directory.Exists(PersonalFolder))
{
try
{
Directory.CreateDirectory(PersonalFolder);
}
catch (Exception e)
{
MessageBox.Show(Resources.Program_Run_Unable_to_create_folder_ + string.Format(" \"{0}\"\r\n\r\n{1}", PersonalFolder, e),
"ShareX - " + Resources.Program_Run_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
CustomPersonalPath = "";
}
}
}
#if STEAM
IsFirstTimeConfig = CLI.IsCommandExist("SteamConfig");
@ -444,6 +416,40 @@ public static void BackupSettings()
Helpers.BackupFileWeekly(HistoryFilePath, BackupFolder);
}
private static void UpdatePersonalPath()
{
IsSandbox = CLI.IsCommandExist("sandbox");
if (!IsSandbox)
{
IsPortable = CLI.IsCommandExist("portable", "p");
if (IsPortable)
{
CustomPersonalPath = PortablePersonalFolder;
}
else
{
IsPortable = File.Exists(PortableCheckFilePath);
CheckPersonalPathConfig();
}
if (!Directory.Exists(PersonalFolder))
{
try
{
Directory.CreateDirectory(PersonalFolder);
}
catch (Exception e)
{
MessageBox.Show(Resources.Program_Run_Unable_to_create_folder_ + string.Format(" \"{0}\"\r\n\r\n{1}", PersonalFolder, e),
"ShareX - " + Resources.Program_Run_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
CustomPersonalPath = "";
}
}
}
}
private static void CheckPersonalPathConfig()
{
string customPersonalPath = ReadPersonalPathConfig();