فهرست منبع

Bug 1671: Shadow-copied WinSCP .NET assembly cannot find winscp.exe in its own original folder, if the folder is an UNC path

https://winscp.net/tracker/1671

Source commit: 7d510b9f469d346c24f0b63451aafbd5faaee8f6
Martin Prikryl 7 سال پیش
والد
کامیت
9db60cde05
1فایلهای تغییر یافته به همراه15 افزوده شده و 4 حذف شده
  1. 15 4
      dotnet/internal/Logger.cs

+ 15 - 4
dotnet/internal/Logger.cs

@@ -24,14 +24,25 @@ namespace WinSCP
             string location = assembly.Location;
             // cannot use Uri.UnescapeDataString, because it treats some characters valid in
             // local path (like #) specially
-            const string protocol = "file:///";
+            const string protocol = "file://";
             if (codeBase.StartsWith(protocol, StringComparison.OrdinalIgnoreCase))
             {
-                path =
-                    codeBase.Substring(protocol.Length).Replace('/', '\\');
+                path = codeBase.Substring(protocol.Length).Replace('/', '\\');
+                if (!string.IsNullOrEmpty(path))
+                {
+                    if (path[0] == '\\')
+                    {
+                        path = path.Substring(1, path.Length - 1);
+                    }
+                    else
+                    {
+                        // UNC path
+                        path = @"\\" + path;
+                    }
+                }
             }
 
-            if ((path == null) || !File.Exists(path))
+            if (string.IsNullOrEmpty(path) || !File.Exists(path))
             {
                 if (File.Exists(location))
                 {