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()); } }
public static int GetLastSlash(string path) { if (RuntimeSystemHelper.IsWindow()) { return(path.LastIndexOf('\\')); } return(path.LastIndexOf('/')); }
public static string CombineRelativePath(string relativePath, string path) { if (RuntimeSystemHelper.IsWindow()) { return(relativePath + "\\" + path); } return(relativePath + "/" + path); }
public static string JoinPath(string[] segments) { if (RuntimeSystemHelper.IsWindow()) { return(string.Join("\\", segments)); } return(string.Join("/", segments)); }
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); }