1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-11 12:15:44 +02:00

Move log file path to a separate property and make sure it always has the correct path

This commit is contained in:
chylex 2016-04-16 14:39:48 +02:00
parent 707b4b4ba2
commit 3c17c36f4f

View File

@ -27,6 +27,12 @@ static class Program{
public static UserConfig UserConfig { get; private set; }
public static string LogFile{
get{
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"td-log.txt");
}
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr LoadLibrary(string name);
@ -90,14 +96,14 @@ public static void HandleException(string message, Exception e){
Log(e.ToString());
if (MessageBox.Show(message+"\r\nDo you want to open the log file to report the issue?",BrandName+" Has Failed :(",MessageBoxButtons.YesNo,MessageBoxIcon.Error,MessageBoxDefaultButton.Button2) == DialogResult.Yes){
Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"td-log.txt"));
Process.Start(LogFile);
}
}
public static void Log(string data){
StringBuilder build = new StringBuilder();
if (!File.Exists("td-log.txt")){
if (!File.Exists(LogFile)){
build.Append("Please, report all issues to: https://github.com/chylex/TweetDick/issues\r\n\r\n");
}
@ -105,7 +111,7 @@ public static void Log(string data){
build.Append(data).Append("\r\n\r\n");
try{
File.AppendAllText("td-log.txt",build.ToString(),Encoding.UTF8);
File.AppendAllText(LogFile,build.ToString(),Encoding.UTF8);
}catch{
// oops
}