Esempio n. 1
0
 public static List <string> GetSegments(string input)
 {
     if (string.IsNullOrEmpty(input))
     {
         return(new List <string>());
     }
     if (RuntimeSystemHelper.IsWindow())
     {
         input = input.Replace('/', '\\');
         input = input.Trim();
         if (input.StartsWith("\\"))
         {
             input = input.Substring(1);
         }
         return(input.Split('\\').ToList());
     }
     else
     {
         input = input.Replace('\\', '/');
         input = input.Trim();
         if (input.StartsWith("/"))
         {
             input = input.Substring(1);
         }
         return(input.Split('/').ToList());
     }
 }
Esempio n. 2
0
 public static int GetLastSlash(string path)
 {
     if (RuntimeSystemHelper.IsWindow())
     {
         return(path.LastIndexOf('\\'));
     }
     return(path.LastIndexOf('/'));
 }
Esempio n. 3
0
 public static string CombineRelativePath(string relativePath, string path)
 {
     if (RuntimeSystemHelper.IsWindow())
     {
         return(relativePath + "\\" + path);
     }
     return(relativePath + "/" + path);
 }
Esempio n. 4
0
        public static string JoinPath(string[] segments)
        {
            if (RuntimeSystemHelper.IsWindow())
            {
                return(string.Join("\\", segments));
            }

            return(string.Join("/", segments));
        }
Esempio n. 5
0
        public static string CombinePath(string root, string relativePath)
        {
            relativePath = relativePath.TrimStart('/');

            string fullpath = string.Empty;

            //url and linux seperate is / ,but window file seperate is \
            if (RuntimeSystemHelper.IsWindow())
            {
                if (relativePath.StartsWith("\\"))
                {
                    relativePath = relativePath.Substring(1);
                }
                var path = relativePath.Replace("/", "\\");
                fullpath = Path.Combine(root, path);
            }
            else
            {
                fullpath = GetCaseInsensitiveFile(root, relativePath);
            }
            return(fullpath);
        }