mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-25 00:15:48 +02:00
Reorganize path constants and allow the program to be portable
This commit is contained in:
parent
e5223a852e
commit
dbeb4c7205
13
Program.cs
13
Program.cs
@ -33,10 +33,15 @@ static class Program{
|
||||
|
||||
public static readonly Version Version = new Version(VersionTag);
|
||||
|
||||
public static readonly string StoragePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), BrandName);
|
||||
public static readonly string PluginPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins");
|
||||
public static readonly string TemporaryPath = Path.Combine(Path.GetTempPath(), BrandName);
|
||||
public static readonly bool IsPortable = File.Exists("makeportable");
|
||||
|
||||
public static readonly string ProgramPath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
public static readonly string StoragePath = IsPortable ? Path.Combine(ProgramPath, "portable", "storage") : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), BrandName);
|
||||
public static readonly string TemporaryPath = IsPortable ? Path.Combine(ProgramPath, "portable", "tmp") : Path.Combine(Path.GetTempPath(), BrandName);
|
||||
public static readonly string ConfigFilePath = Path.Combine(StoragePath, "TD_UserConfig.cfg");
|
||||
|
||||
public static readonly string ScriptPath = Path.Combine(ProgramPath, "scripts");
|
||||
public static readonly string PluginPath = Path.Combine(ProgramPath, "plugins");
|
||||
|
||||
public static uint WindowRestoreMessage;
|
||||
|
||||
@ -47,7 +52,7 @@ static class Program{
|
||||
|
||||
public static string LogFile{
|
||||
get{
|
||||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "td-log.txt");
|
||||
return Path.Combine(ProgramPath, "td-log.txt");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ static class ScriptLoader{
|
||||
|
||||
public static string LoadResource(string name){
|
||||
try{
|
||||
return File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "scripts", name), Encoding.UTF8);
|
||||
return File.ReadAllText(Path.Combine(Program.ScriptPath, name), Encoding.UTF8);
|
||||
}catch(Exception ex){
|
||||
MessageBox.Show("Unfortunately, "+Program.BrandName+" could not load the "+name+" file. The program will continue running with limited functionality.\r\n\r\n"+ex.Message, Program.BrandName+" Has Failed :(", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user