Path
Struct · namespace System
struct PathFile names and paths, as strings: Path.Combine("src", "main.cshift"), Path.GetExtension(file), …
Paths may use / or \; the functions return / separators unless they say otherwise
(Path.ToNative). Nothing here touches the file system except Path.GetFullPath and Path.GetRelativePath,
which read the current directory.
Static methods
Section titled “Static methods”| Name | Description |
|---|---|
Combine |
Joins two path parts with ‘/’ (an empty part is ignored, an absolute second part is returned as it is). |
Normalize |
All separators of path as /. |
ToNative |
The path with the separators of the operating system (for commands that are run by the shell). |
GetDirectory |
The directory part: “a/b/c.txt” -> “a/b”, “c.txt” -> “”. |
GetFileName |
The file name: “a/b/c.txt” -> “c.txt”. |
GetExtension |
The extension including the dot: “c.txt” -> “.txt”, “c” -> “”. |
GetStem |
The file name without directory and extension: “a/b/c.txt” -> “c”. |
ChangeExtension |
The same path with another extension: ChangeExtension("a/b.c", ".o") (or "o") is "a/b.o". |
IsRooted |
Whether path is absolute: "/x", "\\x" and "C:/x" are. |
GetFullPath |
The absolute path, with ‘/’ separators and without “.” and “..” parts (relative paths start at the current directory). |
GetRelativePath |
The path of ‘path’ relative to the directory ‘relativeTo’ (“../lib/a.txt”); both are made absolute first. |
Combine
Section titled “Combine”static string Combine(StringSlice a, StringSlice b)Joins two path parts with ‘/’ (an empty part is ignored, an absolute second part is returned as it is).
Normalize
Section titled “Normalize”static string Normalize(StringSlice path)All separators of path as /.
ToNative
Section titled “ToNative”static string ToNative(StringSlice path)The path with the separators of the operating system (for commands that are run by the shell).
GetDirectory
Section titled “GetDirectory”static string GetDirectory(StringSlice path)The directory part: “a/b/c.txt” -> “a/b”, “c.txt” -> “”.
GetFileName
Section titled “GetFileName”static string GetFileName(StringSlice path)The file name: “a/b/c.txt” -> “c.txt”.
GetExtension
Section titled “GetExtension”static string GetExtension(StringSlice path)The extension including the dot: “c.txt” -> “.txt”, “c” -> “”.
GetStem
Section titled “GetStem”static string GetStem(StringSlice path)The file name without directory and extension: “a/b/c.txt” -> “c”.
ChangeExtension
Section titled “ChangeExtension”static string ChangeExtension(StringSlice path, StringSlice extension)The same path with another extension: ChangeExtension("a/b.c", ".o") (or "o") is "a/b.o".
IsRooted
Section titled “IsRooted”static bool IsRooted(StringSlice path)Whether path is absolute: "/x", "\\x" and "C:/x" are.
Since 0.04
GetFullPath
Section titled “GetFullPath”static string GetFullPath(StringSlice path)The absolute path, with ‘/’ separators and without “.” and “..” parts (relative paths start at the current directory).
Since 0.04
GetRelativePath
Section titled “GetRelativePath”static string GetRelativePath(StringSlice relativeTo, StringSlice path)The path of ‘path’ relative to the directory ‘relativeTo’ (“../lib/a.txt”); both are made absolute first. On another drive the absolute path is returned.
Since 0.04