Method IsValidFor
IsValidFor(PathOptions)
Determines whether this path is valid for the specified options.
Declaration
bool IsValidFor(PathOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| PathOptions | options | The path options to check the path against. |
Returns
| Type | Description |
|---|---|
| bool | true if parsing this path's PathDisplay in its PathFormat, as the same kind of path (absolute or
relative, file or directory), with |
Remarks
The options apply as they do when parsing: NoReservedDeviceNames has no effect on Unix paths, control characters are always invalid in Windows paths, PathFormatDependent adds the NoUnfriendlyNames flags for Windows and Universal paths, and AllowEmptyDirectories makes no difference because paths never contain empty directories.
Paths remember what they are known to be valid for. A path that was parsed is known to be valid for the options it was parsed with, and paths derived from it (e.g. its parent directory or a combined path) keep what is known about their names. Anything else is worked out the first time it is needed, in one pass over the names, and remembered for every later check.
IsValidFor(PathOptions, out string?)
Determines whether this path is valid for the specified options and outputs the reason when it isn't.
Declaration
bool IsValidFor(PathOptions options, out string? errorMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| PathOptions | options | The path options to check the path against. |
| string | errorMessage | When this method returns false, contains the error message that parsing this path with |
Returns
| Type | Description |
|---|---|
| bool | true if parsing this path's PathDisplay in its PathFormat, as the same kind of path (absolute or
relative, file or directory), with |
Remarks
See IsValidFor(PathOptions) for how the options apply. The error message is only worked out when the path isn't valid.