diff --git a/OnPSApp/Models/GameStatisticModel.cs b/OnPSApp/Models/GameStatisticModel.cs index 5e752cd..98f9d4f 100644 --- a/OnPSApp/Models/GameStatisticModel.cs +++ b/OnPSApp/Models/GameStatisticModel.cs @@ -24,7 +24,7 @@ class GameStatisticModel public GameStatisticModel(String onlineId, String platform, String npTitleId, String titleName, String npTitleIconUrl) { - string folderPath = Application.StartupPath + "/profiles/"+ onlineId + "/"+platform+"/"; + string folderPath = Program.SavePath + "/profiles/"+ onlineId + "/"+platform+"/"; bool exists = System.IO.Directory.Exists(folderPath); @@ -117,7 +117,7 @@ public void SaveData() public static ArrayList GetAvailablePlatforms(String onlineId) { - String Path = Application.StartupPath + @"\profiles\" + onlineId; + String Path = Program.SavePath + @"\profiles\" + onlineId; if (!Directory.Exists(Path)) { Directory.CreateDirectory(Path); @@ -136,7 +136,7 @@ public static ArrayList GetAvailablePlatforms(String onlineId) public static ArrayList GetFiles(String onlineId, String platform) { - String Path = Application.StartupPath + @"\profiles\" + onlineId + @"\" + platform + @"\"; + String Path = Program.SavePath + @"\profiles\" + onlineId + @"\" + platform + @"\"; if (!Directory.Exists(Path)) { Directory.CreateDirectory(Path); diff --git a/OnPSApp/Other/IniFile.cs b/OnPSApp/Other/IniFile.cs index 0b4d5d2..7ac2951 100644 --- a/OnPSApp/Other/IniFile.cs +++ b/OnPSApp/Other/IniFile.cs @@ -9,7 +9,7 @@ namespace OnPS.Other class IniFile // revision 11 { string Path; - string EXE = Assembly.GetExecutingAssembly().GetName().Name; + string ApplicationName = "OnPS"; [DllImport("kernel32", CharSet = CharSet.Unicode)] static extern long WritePrivateProfileString(string Section, string Key, string Value, string FilePath); @@ -19,29 +19,29 @@ class IniFile // revision 11 public IniFile(string IniPath = null) { - Path = new FileInfo(IniPath + EXE + ".ini").FullName.ToString(); + Path = new FileInfo(IniPath + ApplicationName + ".ini").FullName.ToString(); } public string Read(string Key, string Section = null) { var RetVal = new StringBuilder(255); - GetPrivateProfileString(Section ?? EXE, Key, "", RetVal, 255, Path); + GetPrivateProfileString(Section ?? ApplicationName, Key, "", RetVal, 255, Path); return RetVal.ToString(); } public void Write(string Key, string Value, string Section = null) { - WritePrivateProfileString(Section ?? EXE, Key, Value, Path); + WritePrivateProfileString(Section ?? ApplicationName, Key, Value, Path); } public void DeleteKey(string Key, string Section = null) { - Write(Key, null, Section ?? EXE); + Write(Key, null, Section ?? ApplicationName); } public void DeleteSection(string Section = null) { - Write(null, null, Section ?? EXE); + Write(null, null, Section ?? ApplicationName); } public bool KeyExists(string Key, string Section = null) diff --git a/OnPSApp/Program.cs b/OnPSApp/Program.cs index 66f700a..9b17a43 100644 --- a/OnPSApp/Program.cs +++ b/OnPSApp/Program.cs @@ -12,6 +12,7 @@ namespace OnPS { static class Program { + public static String SavePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/OnPS/"; public const String VERSION = "1.0.0.0"; public static NotifyIcon notifyIcon; public static bool steamAvailable = false; @@ -59,6 +60,10 @@ static void Main(string[] args) AllocConsole(); } } + bool exists = System.IO.Directory.Exists(SavePath); + + if (!exists) + System.IO.Directory.CreateDirectory(SavePath); using (mutex = new Mutex(false, appGuid)) { if (!mutex.WaitOne(0, false)) @@ -66,7 +71,7 @@ static void Main(string[] args) MessageBox.Show("OnPS already running.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - iniFile = new IniFile(Application.StartupPath+@"\"); + iniFile = new IniFile(SavePath + @"\"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate (object senderr, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) {