PathHelper.NormalizePathSegments Method

Namespace
Kampute.DocToolkit.Support
Assembly
  • Kampute.DocToolkit.dll

Definition

Normalizes a collection of path segments by resolving relative segments like ".." and ".".
public static List<string> NormalizePathSegments(IEnumerable<string> pathSegments)

Parameters

pathSegments IEnumerable<string>
The collection of path segments to normalize.

Returns

List<string>
A list of normalized path segments.

Exceptions

ArgumentNullException
Thrown when pathSegments is null.

Remarks

This method processes path segments to resolve:
  • "." segments, which are removed as they refer to the current directory.
  • ".." segments, which navigate to the parent directory by removing the previous segment.
If there are more ".." segments than parent directories available, the extra ".." segments are preserved at the beginning.