1
0
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:
chylex 2016-09-02 20:59:03 +02:00
parent e5223a852e
commit dbeb4c7205
2 changed files with 10 additions and 5 deletions

View File

@ -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");
}
}

View File

@ -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;