Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Static class: RT.Util.PathUtil

Summary

Provides path-related utilities.

Static methods

string
AppendBeforeExtension(string filename, string value)
Appends the specified value to the filename part before extension.
string
AppPathCombine(string path)
Combines the full path containing the running executable with the specified string. Ensures that only a single Path.DirectorySeparatorChar separates the two.
string
AppPathCombine(params string[] morePaths)
Combines the full path containing the running executable with one or more strings. Ensures that only a single Path.DirectorySeparatorChar separates the executable path and every string.
string
Combine(string path1, string path2)
Joins the two paths using the OS separator character. If the second path is absolute, only the second path is returned.
string
Combine(string path1, string path2, params string[] morepaths)
Joins multiple paths using the OS separator character. If any of the paths is absolute, all preceding paths are discarded.
void
CreatePathToFile(string filename)
Creates all directories in the path to the specified file if they don't exist. Accepts filenames relative to the current directory.
void
DeleteEmptyDirs(string path)
Deletes the specified directory only if it is empty, and then checks all parents to see if they have become empty too. If so, deletes them too. Does not throw any exceptions.
string
ExpandPath(string path)
Expands all occurrences of "$(NAME)" in the specified string with the special folder path for the current machine/user. See remarks for details. (see also remarks)
IEnumerable<string>
ExpandWildcards(string filenameOrPattern, bool matchFiles = true, bool matchDirectories = false, bool includeSubdirectories = false)
Given a filename or a pattern containing * or ? wildcards, enumerates all names matching the wildcard.
string
ExtractNameAndExt(string path)
Returns the name and extension of the last group in the specified path, separated by either of the two slashes.
string
ExtractParent(string path)
Returns the "parent" path of the specified path by removing the last name from the path, separated by either forward or backslash. If the original path ends in slash, the returned path will also end with a slash.
string
ExtractParent(string path, char separator)
Returns the "parent" path of the specified path by removing the last group from the path, separated by the "separator" character. If the original path ends in slash, the returned path will also end with a slash.
string
GetFullPath(string path)
Returns the full path pointing to the same file/directory as path. Converts relative paths to absolute paths where necessary, relative to the current working directory. This is the same as Path.GetFullPath(string), except that this function returns the actual on-disk capitalization for each segment, regardless of how they are capitalized in path. If the path does not exist in full, corrects the capitalization of the segments that do exist. Always capitalizes the drive letter.
bool
IsSubpathOf(string subpath, string parentPath)
Checks whether subpath refers to a subdirectory inside parentPath.
bool
IsSubpathOfOrSame(string subpath, string parentPath)
Checks whether subpath refers to a subdirectory inside parentPath or the same directory.
string
NormPath(string path)
Normalises the specified path. A "normalised path" is a path to a directory (not a file!) which always ends with a slash.
string Strips a single trailing directory separator, whether it's the forward- or backslash. Preserves the single separator at the end of paths referring to the root of a drive, such as "C:\". Removes at most a single separator, never more.
string
ToggleRelative(string basePath, string toggledPath)
Changes a relative toggledPath to an absolute and vice versa, with respect to basePath. Neither path must be an empty string. Any trailing slashes are ignored and the result won't have one except for root "C:\"-style paths. Forward slashes, multiple repeated slashes, and any redundant "." or ".." elements are correctly interpreted and eliminated. See Remarks for some special cases. (see also remarks)
string
UnexpandPath(string path)
Checks to see whether the specified path starts with any of the standard paths supported by PathUtil.ExpandPath(string), and if so, replaces the prefix with a "$(NAME)" string and returns the resulting value. The value passed in should be an absolute path for the substitution to work.

Static properties

string Returns the full path to the directory containing the application's entry assembly. Will succeed for the main AppDomain of an application started as an .exe; will throw for anything that doesn't have an entry assembly, such as a manually created AppDomain.