public static string ResolveRelativePath(string basePath, string relativePath) { //~~ TODO: Need to test if (DWPSUtils.IsFullPath(relativePath)) { return(relativePath); } if (string.IsNullOrEmpty(relativePath)) { return(basePath); } var dirPath = GetDirectoryPath(basePath); if (dirPath == null) { return(relativePath); } var tempPath = _diskManager.Path.Combine(dirPath, relativePath); if (_diskManager.Directory.Exists(tempPath)) { return(_diskManager.NewDirectoryInfo(tempPath).FullName); } return(_diskManager.NewFileInfo(tempPath).FullName); }
public static string GetFullPath(string basePath, string name) { if (DWPSUtils.IsFullPath(name)) { return(name); } if (string.IsNullOrWhiteSpace(name)) { if (DWPSUtils.IsFullPath(basePath)) { return(basePath); } else { throw new DirectoryNotFoundException("Either the base path or the file name must be a valid path"); } } var relPath = _diskManager.Path.Combine(basePath, name); var relInfo = _diskManager.NewFileInfo(relPath); return(relInfo.FullName); }