public static bool IsValidRelativePath(string path, out string reason) { reason = string.Empty; if (path == null) { reason = "Input path string is null"; return(false); } if (path.Length == 0) { reason = "Empty string for path"; return(false); } if (!InternalStringHelper.CanOnlyBeARelativePath(path)) { reason = "An absolute path was inputed where a relative path was expected."; return(false); } path = InternalStringHelper.NormalizePath(path); if (InternalStringHelper.ContainsInnerSpecialDir(path)) { string unusedPath; if (!InternalStringHelper.TryResolveInnerSpecialDir(path, out unusedPath, out reason)) { return(false); } } return(true); }
//---------------------------------------- // // Path String Validity // //---------------------------------------- public static bool IsValidAbsolutePath(string path, out string reason) { reason = string.Empty; if (path == null) { reason = "Input path string is null"; return(false); } if (path.Length == 0) { reason = "Empty string for path"; return(false); } if (InternalStringHelper.CanOnlyBeARelativePath(path)) { reason = "A relative path was inputed where an absolute path was expected."; return(false); } if (InternalStringHelper.IsUniformRessourceLocatorPath(path)) { reason = "URN (UniformRessourceLocator) paths are not supported."; return(false); } if (!InternalStringHelper.BeginsWithASingleLetterDrive(path)) { reason = "The absolute path doesn't begin with a single letter drive followed by ':'."; return(false); } path = InternalStringHelper.NormalizePath(path); if (InternalStringHelper.ContainsInnerSpecialDir(path)) { string unusedPath; if (!InternalStringHelper.TryResolveInnerSpecialDir(path, out unusedPath, out reason)) { return(false); } } return(true); }