Rebex
Products Downloads Buy Support Contact
Show / Hide Table of Contents

NodePath Class

Namespace: Rebex.IO.FileSystem
Assembly: Rebex.Common.dll (version 7.0.9147)

Represents a file system path.

Syntax
public sealed class NodePath : IEnumerable<string>, IEnumerable, IEquatable<NodePath>
Inheritance
Object
NodePath
Implements
IEnumerable<String>
IEnumerable
IEquatable<NodePath>
Inherited Members
Object.Equals(Object, Object)
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)

Remarks

Instances of NodePath are case-insensitive, which means that Equals(NodePath) method (and the default IEqualityComparer available in Comparer property) treat all the following paths as equal:

  • /ab/
  • /AB/
  • /aB/
  • /Ab/
If the need to use the case-sensitive paths arises, consider implementing a case-insensitive IEqualityComparer<T> for the NodePath.

Constructors

Name Description
NodePath(String)

Initializes a new instance of the NodePath.

Examples of the valid path:

/

/dir1

/dir1/

/dir1/dir2

/dir1/dir2/

/dir1/dir2/file.txt

Fields

Name Description
DirectorySeparator

Used directory separator.

Empty

Represents the empty NodePath.

RootDirectoryName

Name of the root directory.

Properties

Name Description
AllowBackslashInFileName

Gets or sets a value indicating whether the backslash ('&apos;) character is allowed in FileName property. The default value is false, the backslash character is not allowed. Be aware that after the property is set to true, custom providers derived from the ReadOnlyFileSystemProvider and ReadWriteFileSystemProvider MUST check and sanitize all paths to prevent miscellaneous variations of path/directory traversal attacks.

Comparer

Gets the IEqualityComparer that is used to determine equality of NodePath.

Extension

Gets the file name extension, or Empty if this path does not have extension.

FileName

Gets the name of the DirectoryNode or the FileNode.

FileNameWithoutExtension

Gets the name without an extension.

HasExtension

Indicates whether a path contains file name extension.

IsEmpty

Returns true if this path equals to Empty path, otherwise returns false.

IsRootPath

Indicates if this instance is the root path ('/').

Item[Int32]

Returns an element of this path.

ParentPath

Gets the parent path, or Empty path if this path does not have parent.

PathParts

Gets an enumerator that iterates through the elements of this path.

PathPartsCount

Returns the number of elements in the path.

StringPath

Returns this NodePath as a String.

Methods

Name Description
AddExtension(String)

Creates new NodePath with extension added to this NodePath.

AddPathPart(String)

Creates new NodePath with pathPart added to the end of this NodePath.

ChangeExtension(String)

Creates new NodePath based on this NodePath and with the new extension.

Combine(String[])

Combines strings in the pathParts array into a NodePath.

Equals(NodePath)

Indicates whether the current NodePath is equal to another NodePath.

Equals(Object)

Determines whether the specified NodePath is equal to the current NodePath.

GetEnumerator()

Gets an enumerator that iterates through the elements of this path.

GetHashCode()

Gets a hash code of this object.

GetInvalidFileNameChars()

Returns an array of characters not allowed in Name.

GetSubPath(Int32)

Returns a subpath that is a subsequence of the parts of this path. Subpath starts with the first part (on the index 0) of this path and ends with the part on the index subPathEndIndex.

Root path ('/') does not have any subpath.

For the NodePath with the path '/dir1/dir2/file.txt';

GetSubPath(0) returns '/dir1'.

GetSubPath(1) returns '/dir1/dir2'.

GetSubPath(2) returns 'dir1/dir2/file.txt'.

GetSubPath(3) throws ArgumentOutOfRangeException.

IsNullOrEmpty(NodePath)

Indicates whether the specified NodePath is null or an Empty instance of the NodePath.

RemoveExtension()

Creates new NodePath based on this NodePath and with the extension deleted.

StartsWith(NodePath)

Tests if this NodePath starts with the given otherPath.

ToString()

Returns a string that represents the current NodePath.

Operators

Name Description
Equality(NodePath, NodePath)

Determines whether two specified NodePath have the same value.

Explicit(NodePath to String)

Convert the value of the path to the string representation.

Implicit(String to NodePath)

Convert the value of path to the instance of the NodePath.

Inequality(NodePath, NodePath)

Determines whether two specified NodePath have different values.

Explicit Interface Implementations

Name Description
IEnumerable.GetEnumerator()

Gets an enumerator that iterates through the elements of this path.

In This Article
  • Remarks
  • Constructors
  • Fields
  • Properties
  • Methods
  • Operators
  • Explicit Interface Implementations
© REBEX ČR s.r.o. Back to top
Privacy policy
Manage cookies