# HG changeset patch # User IBBoard # Date 1313232177 0 # Node ID 0f88d32b22cc0349b032718ee830a99a999b9f44 # Parent a78efc8b2119be97c962c889d12a92bcef3029b1 * Swap to built-in .Net methods (listed on http://www.ironshay.com/post/Use-NET-Built-in-Methods-to-Save-Time-and-Headaches.aspx) no-open-ticket diff -r a78efc8b2119 -r 0f88d32b22cc Constants.cs --- a/Constants.cs Sun Aug 07 19:13:19 2011 +0000 +++ b/Constants.cs Sat Aug 13 10:42:57 2011 +0000 @@ -18,20 +18,10 @@ static Constants() { - string exe = Environment.GetCommandLineArgs()[0]; - int slash = exe.LastIndexOf(DirectoryChar) + 1; - int dot = exe.LastIndexOf('.'); - - if (dot > slash) - { - exe = exe.Substring(slash, dot - slash); - } - else - { - exe = exe.Substring(slash); - } - - userDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).TrimEnd(DirectoryChar) + DirectoryChar + "IBBoard" + DirectoryChar + exe; + string appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + string exe = Environment.GetCommandLineArgs()[0]; + exe = Path.GetFileNameWithoutExtension(exe); + userDataPath = Path.Combine(Path.Combine(appDataDir, "IBBoard"), exe); } public static string ExecutablePath @@ -45,13 +35,5 @@ { get { return userDataPath; } } - - /*public static void RecreateUserDataPath(string path) - { - if (path!=null && path!="") - { - userDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)+DirectoryChar+path.Trim(DirectoryChar); - } - }*/ } } diff -r a78efc8b2119 -r 0f88d32b22cc Logging/FileLogger.cs --- a/Logging/FileLogger.cs Sun Aug 07 19:13:19 2011 +0000 +++ b/Logging/FileLogger.cs Sat Aug 13 10:42:57 2011 +0000 @@ -32,7 +32,7 @@ public static string MakeLogFilePath(string path) { - return path.TrimEnd(IBBoard.Constants.DirectoryChar) + IBBoard.Constants.DirectoryChar + "logs" + IBBoard.Constants.DirectoryChar + String.Format("{0:yyyy-MM-dd-HHmmss}", DateTime.Now)+".log"; + return Path.Combine(Path.Combine(path, "logs"), String.Format("{0:yyyy-MM-dd-HHmmss}.log", DateTime.Now)); } public static FileStream CreateDefaultLogFileStream() diff -r a78efc8b2119 -r 0f88d32b22cc Preferences.cs --- a/Preferences.cs Sun Aug 07 19:13:19 2011 +0000 +++ b/Preferences.cs Sat Aug 13 10:42:57 2011 +0000 @@ -32,22 +32,12 @@ LoadPreferences(); } - /*public Preferences(string appExecPath, string appName, string fullUserDataDir) - { - LoadPreferences(appExecPath.TrimEnd(Constants.DirectoryChar) + Constants.DirectoryChar + appName + "Pref.xml", fullUserDataDir.TrimEnd(Constants.DirectoryChar)); - } - - public Preferences(string filepath, string appDir) - { - LoadPreferences(filepath, appDir); - }*/ - private void LoadPreferences() { htGlobal = new Hashtable(); htLocal = new Hashtable(); - string globalPath = Constants.ExecutablePath + Constants.DirectoryChar + app + "Pref.xml"; + string globalPath = Path.Combine(Constants.ExecutablePath, app + "Pref.xml"); if (File.Exists(globalPath)) { @@ -113,7 +103,7 @@ private void LoadLocalPreferences() { - string path = Constants.UserDataPath + Constants.DirectoryString + "preferences.xml"; + string path = Path.Combine(Constants.UserDataPath, "preferences.xml"); if (File.Exists(path)) { @@ -287,6 +277,8 @@ public void Save() { + string prefPath = Path.Combine(Constants.UserDataPath, "preferences.xml"); + if (htLocal.Count>0) { XmlDocument xmld = new XmlDocument(); @@ -354,12 +346,12 @@ { Directory.CreateDirectory(Constants.UserDataPath); } - - xmld.Save(Constants.UserDataPath + Constants.DirectoryString + "preferences.xml"); + + xmld.Save(prefPath); } - else if (File.Exists(Constants.UserDataPath + Constants.DirectoryString + "preferences.xml")) + else if (File.Exists(prefPath)) { - File.Delete(Constants.UserDataPath + Constants.DirectoryString + "preferences.xml"); + File.Delete(prefPath); } modified = false; diff -r a78efc8b2119 -r 0f88d32b22cc Xml/IBBXmlResolver.cs --- a/Xml/IBBXmlResolver.cs Sun Aug 07 19:13:19 2011 +0000 +++ b/Xml/IBBXmlResolver.cs Sat Aug 13 10:42:57 2011 +0000 @@ -24,7 +24,7 @@ if (relativeUri.StartsWith("dtds/")) { //Uri uri = base.ResolveUri(baseUri, relativeUri); - return new Uri(Uri.UriSchemeFile + "://" + baseFilePath + Constants.DirectoryString + relativeUri); + return new Uri(Uri.UriSchemeFile + "://" + baseFilePath + "/" + relativeUri); } else {