Interface IPath
Represents a path, absolute or relative, to a file or to a directory.
public interface IPath
- Extension Methods
Remarks
Equals(), ToString() and GetHashCode() operations are overridden from System.Object and are supported by all paths objects. Equals() and GetHashCode() are string case insensitive.
Properties (9)
HasParentDirectory
Gets a value indicating whether this path has a parent directory path
bool HasParentDirectory { get; }
Property Value
- bool
true if this path has a parent directory path, else returns false.
Remarks
Root directories representing a drive, like C: or D: don't have a parent directory path. Relative path like "." or ".." don't have a parent directory path. Notice that a file path necessarily has a parent directory path.
IsAbsolutePath
Gets a value indicating whether this path is an absolute path.
bool IsAbsolutePath { get; }
Property Value
- bool
true if this path is an absolute path, else returns false.
Remarks
An absolute path can be down-casted to IAbsolutePath. A IAbsolutePath can be down-casted to a IAbsoluteFilePath or (exclusive) a IAbsoluteDirectoryPath.
IsDirectoryPath
Gets a value indicating whether this path is a directory path.
bool IsDirectoryPath { get; }
Property Value
- bool
true if this path is a directory path, else returns false.
Remarks
A relative path can be down-casted to IDirectoryPath. A IDirectoryPath can be down-casted to a IRelativeDirectoryPath or (exclusive) a IAbsoluteDirectoryPath.
IsEnvVarPath
Gets a value indicating whether this path is prefixed with an environment variable.
bool IsEnvVarPath { get; }
Property Value
- bool
true if this path is prefixed with an environment variable, else returns false.
Remarks
A path prefixed with an environment variable can be down-casted to IEnvVarPath. A IEnvVarPath can be down-casted to a IEnvVarFilePath or (exclusive) a IEnvVarDirectoryPath.
IsFilePath
Gets a value indicating whether this path is a file path.
bool IsFilePath { get; }
Property Value
- bool
true if this path is a file path, else returns false.
Remarks
A relative path can be down-casted to IFilePath. A IFilePath can be down-casted to a IRelativeFilePath or (exclusive) a IAbsoluteFilePath.
IsRelativePath
Gets a value indicating whether this path is a relative path.
bool IsRelativePath { get; }
Property Value
- bool
true if this path is a relative path, else returns false.
Remarks
A relative path can be down-casted to IRelativePath. A IRelativePath can be down-casted to a IRelativeFilePath or (exclusive) a IRelativeDirectoryPath.
IsVariablePath
Gets a value indicating whether this path contains variable(s).
bool IsVariablePath { get; }
Property Value
- bool
true if this path contains variable(s), else returns false.
Remarks
A path contains variable(s) can be down-casted to IVariablePath. A IVariablePath can be down-casted to a IVariableFilePath or (exclusive) a IVariableDirectoryPath.
ParentDirectoryPath
Returns the parent directory path.
IDirectoryPath ParentDirectoryPath { get; }
Property Value
Exceptions
- InvalidOperationException
This path doesn't have a parent directory path. Root directories representing a drive, like C: or D: don't have a parent directory path. Relative path like "." or ".." don't have a parent directory path. Notice that a file path necessarily has a parent directory path.
PathMode
Gets a value indicating this path mode as defined in the enumeration PathMode.
PathMode PathMode { get; }
Property Value
Methods (2)
IsChildOf(IDirectoryPath)
Gets a value indicating whether this path is a child path of parentDirectory.
bool IsChildOf(IDirectoryPath parentDirectory)
Parameters
parentDirectoryIDirectoryPathThe parent directory.
Returns
- bool
true of this directory is a child directory of
parentDirectory, else false.
Remarks
This path resource nor parentDirectory need to exist for this operation to complete properly.
NotEquals(object)
Returns true if obj is null, is not an IPath, or is an IPath representing a different path than this path (case insensitive).
bool NotEquals(object obj)
Parameters
objobject
Returns
Remarks
This method is the opposite of the IPath.Equals() method, overridden from System.Object. It can be used to make the negation in !Equals more obvious.