Version 3.3.1.2

PathUtilities class

Namespace: Sirenix.Utilities
Assembly: Sirenix.Utilities
public static class PathUtilities
DirectoryInfo method extensions.
Inheritance
  • System.Object
  • PathUtilities

Methods

CanMakeRelative(String, String)
Returns a value indicating whether or not a path can be made relative to another.
public static bool CanMakeRelative(string absoluteParentPath, string absolutePath)
Parameters
System.String absoluteParentPath

The parent path.

System.String absolutePath

The path to make relative to the parent path.

Returns
System.Boolean

A value indicating if the path can be made relative to the parent path.

Combine(String, String)
Combines two paths, and replaces all backslases with forward slash.
public static string Combine(string a, string b)
Parameters
System.String a

System.String b

Returns
System.String

FindParentDirectoryWithName(DirectoryInfo, String)
Finds a parent directory with a given name, or null if no such parent directory exists.
public static DirectoryInfo FindParentDirectoryWithName(this DirectoryInfo dir, string folderName)
Parameters
System.IO.DirectoryInfo dir

System.String folderName

Returns
System.IO.DirectoryInfo

GetDirectoryName(String)
Gets the name of the directory. Always returns forward slash seperators as opposed to Path.GetDirectoryName().
public static string GetDirectoryName(string x)
Parameters
System.String x

Returns
System.String

HasSubDirectory(DirectoryInfo, DirectoryInfo)
Determines whether the directory has a given directory in its hierarchy of children.
public static bool HasSubDirectory(this DirectoryInfo parentDir, DirectoryInfo subDir)
Parameters
System.IO.DirectoryInfo parentDir

The parent directory.

System.IO.DirectoryInfo subDir

The sub directory.

Returns
System.Boolean

MakeRelative(String, String)
Returns a path string to path that is relative to the parent path.
public static string MakeRelative(string absoluteParentPath, string absolutePath)
Parameters
System.String absoluteParentPath

The parent path.

System.String absolutePath

The path to make relative to the parent path.

Returns
System.String

A relative path from parent path to path.

TryMakeRelative(String, String, out String)
Tries to make a path that is relative from parent path to path.
public static bool TryMakeRelative(string absoluteParentPath, string absolutePath, out string relativePath)
Parameters
System.String absoluteParentPath

The parent path.

System.String absolutePath

The path to make relative to the parent path.

System.String relativePath

A relative path from parent path to path. null if no relative path could be made.

Returns
System.Boolean

A value indicating if the method succeeded in making a relative path.