String operations for file paths.
String operations for file paths.
Gets the file extension for the given path, including the period. If there is no file extension, this returns an empty string. For example, hello.txt
will return .txt
.
string
Returns true if the given path has a file extension.
bool
Changes the file extension in the given path and returns the new path. If the original path has no file extension, this will add the given file extension.
string
Removes the file extension from the given path. If there is no file extension, this returns the original path. For example, hello.txt
will return hello
.
string
Combines two paths into one. This automatically glues the paths with forward slashes where needed. For example, passing hello
and world
will return hello/world
, but so will passing hello/
and world
. You should not combine multiple absolute paths using this function.
string
Returns true if the given 2 paths can be considered equal.
bool
Returns the path to the directory of the containing path, including the path separator, excluding the filename. For example, hello/world/foo.txt
will return hello/world/
.
string
Gets the file name and extension of the given path. For example, hello/world/foo.txt
will return foo.txt
.
string
Gets the file name of the given path without the extension. For example, hello/world/foo.txt
will return foo
.
string
Sanitizes the given filename and replaces invalid characters with underscores. You may use this for both file names and folder names.
string