OSDN Git Service

実行ファイルのあるディレクトリの取得方法を変更する
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Thu, 24 Sep 2015 15:48:47 +0000 (00:48 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Fri, 25 Sep 2015 11:53:14 +0000 (20:53 +0900)
KancolleSniffer/Config.cs
KancolleSniffer/LogServer.cs
KancolleSniffer/Logger.cs
KancolleSniffer/Status.cs

index c4a15e1..182a7d0 100644 (file)
@@ -19,7 +19,6 @@ using System;
 using System.Collections.Generic;\r
 using System.Drawing;\r
 using System.IO;\r
-using System.Windows.Forms;\r
 using Codeplex.Data;\r
 \r
 namespace KancolleSniffer\r
@@ -79,7 +78,7 @@ namespace KancolleSniffer
 \r
     public class Config\r
     {\r
-        private readonly string _baseDir = Path.GetDirectoryName(Application.ExecutablePath);\r
+        private readonly string _baseDir = AppDomain.CurrentDomain.BaseDirectory;\r
         private readonly string _configFileName;\r
 \r
         public Point Location { get; set; }\r
@@ -171,21 +170,12 @@ namespace KancolleSniffer
 \r
         private string StripBaseDir(string path)\r
         {\r
-            if (_baseDir == null)\r
-                return path;\r
             if (!path.StartsWith(_baseDir))\r
                 return path;\r
             path = path.Substring(_baseDir.Length);\r
             return path.StartsWith(Path.DirectorySeparatorChar.ToString()) ? path.Substring(1) : path;\r
         }\r
 \r
-        private string PrependBaseDir(string path)\r
-        {\r
-            if (_baseDir == null)\r
-                return path;\r
-            if (Path.IsPathRooted(path))\r
-                return path;\r
-            return Path.Combine(_baseDir, path);\r
-        }\r
+        private string PrependBaseDir(string path) => Path.IsPathRooted(path) ? path : Path.Combine(_baseDir, path);\r
     }\r
 }
\ No newline at end of file
index 509ce00..166b50f 100644 (file)
@@ -24,15 +24,14 @@ using System.Net.Sockets;
 using System.Text;\r
 using System.Threading;\r
 using System.Web;\r
-using System.Windows.Forms;\r
 \r
 namespace KancolleSniffer\r
 {\r
     public class LogServer\r
     {\r
         private readonly TcpListener _listener;\r
-        private readonly string _indexDir = Path.GetDirectoryName(Application.ExecutablePath);\r
-        private string _outputDir = Path.GetDirectoryName(Application.ExecutablePath);\r
+        private readonly string _indexDir = AppDomain.CurrentDomain.BaseDirectory;\r
+        private string _outputDir = AppDomain.CurrentDomain.BaseDirectory;\r
 \r
         public int Port { get; private set; }\r
 \r
index e1615bc..a3ee34a 100644 (file)
 using System;\r
 using System.Collections.Generic;\r
 using System.IO;\r
-using System.Text;\r
 using System.Linq;\r
+using System.Text;\r
 using System.Web;\r
-using System.Windows.Forms;\r
 \r
 namespace KancolleSniffer\r
 {\r
@@ -376,7 +375,7 @@ namespace KancolleSniffer
 \r
         public LogWriter(string outputDir = null, IFile file = null)\r
         {\r
-            _outputDir = outputDir ?? Path.GetDirectoryName(Application.ExecutablePath);\r
+            _outputDir = outputDir ?? AppDomain.CurrentDomain.BaseDirectory;\r
             _file = file ?? new FileWrapper();\r
         }\r
 \r
index ff4797a..5dd36b1 100644 (file)
@@ -17,7 +17,6 @@
 \r
 using System;\r
 using System.IO;\r
-using System.Windows.Forms;\r
 using Codeplex.Data;\r
 \r
 namespace KancolleSniffer\r
@@ -31,10 +30,7 @@ namespace KancolleSniffer
 \r
     public class Status\r
     {\r
-        // ReSharper disable once AssignNullToNotNullAttribute\r
-        private readonly string _statusFileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath),\r
-            "status.json");\r
-\r
+        private readonly string _statusFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "status.json");\r
         public static bool Restoring { get; set; }\r
         public int ExperiencePoint { get; set; }\r
         public DateTime LastResetTime { get; set; }\r