瀏覽代碼

:bug: 修复路径可能为空导致创建相对路径报错的问题

liufei 3 年之前
父節點
當前提交
896dc26f11
共有 1 個文件被更改,包括 1 次插入15 次删除
  1. 1 15
      Util/FileUtil.cs

+ 1 - 15
Util/FileUtil.cs

@@ -159,21 +159,7 @@ namespace GeekDesk.Util
 
         public static string MakeRelativePath(string fromPath, string toPath)
         {
-            //if (string.IsNullOrEmpty(fromPath)) throw new ArgumentNullException("fromPath");
-            //if (string.IsNullOrEmpty(toPath)) throw new ArgumentNullException("toPath");
-
-            //Uri fromUri = new Uri(fromPath);
-            //Uri toUri = new Uri(toPath);
-
-            //if (fromUri.Scheme != toUri.Scheme) { return toPath; } // path can't be made relative.
-
-            //Uri relativeUri = fromUri.MakeRelativeUri(toUri);
-            //string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
-
-            //if (toUri.Scheme.Equals("file", StringComparison.InvariantCultureIgnoreCase))
-            //{
-            //    relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
-            //}
+            if (string.IsNullOrEmpty(toPath) || string.IsNullOrEmpty(fromPath)) return null;
             Uri file = new Uri(@toPath);
             // Must end in a slash to indicate folder
             Uri folder = new Uri(@fromPath);