/// <summary> /// /// </summary> /// <param name="path"></param> /// <returns></returns> public string GetConfigPath(string path) { string configPath = path; if (StringHelper.IsEmpty(configPath)) { configPath = string.Empty; } if (!configPath.StartsWith("~/")) { configPath = string.Format("{0}/{1}", AppRootPath.TrimEnd('/', '\\'), path.TrimStart('/', '\\')); } return(configPath); }
/// <summary> /// Converts a relative path or an app relative path to a rooted path (from the application root). Always starts with "/" /// </summary> /// /// <param name="path"> /// Full pathname to search. /// </param> /// /// <returns> /// path as a string. /// </returns> public string MapToAppRelativePath(string path) { path = ResolveParents(NormalizeSlashes(path)); if (IsUrl(path) || path.StartsWith("~/")) { return(path); } // it's a file-relative path, add the ScriptPath if (!path.StartsWith("/")) { return(RelativePathRoot + path); } // if we're here, the path starts with a slash so it's rooted. // the virtual root is the same - just add a tilde if (FileSystemRootPath.Length == AppRootPath.Length) { return("~" + path); } else { int folders = AppRootPath.Substring(FileSystemRootPath.Length).Split('\\').Length; string prefix = ""; for (int i = 0; i < folders; i++) { prefix += "/.."; } return("~" + prefix + path); } }