System::IO::Path class
Contents
[
Hide
]Path class
Provides methods for manipulating paths. This is a static type with no instance services. You should never create instances of it by any means.
class Path
Methods
Method | Description |
---|---|
static ChangeExtension(const String&, const String&) | Changes the extension in the specified file path. |
static CheckPath(const String&, const String&, bool) | Determines if the specified path is valid by checking if it contains invalid characters. An exception is thrown if the path contains invalid characters. |
static Combine(const ArrayPtr<String>&) | Combines the specified path segments into a single path inserting directory separator characters between the segments if necessary. |
static Combine(const String&, const String&) | Combines two specified path segments into a single path inserting directory separator character between the segments if necessary. |
static Combine(const String&, const String&, const String&) | Combines three specified path segments into a single path inserting directory separator characters between the segments if necessary. |
static Combine(const String&, const String&, const String&, const String&) | Combines four specified path segments into a single path inserting directory separator characters between the segments if necessary. |
static GetDirectoryName(const String&) | Returns the name of the directory referenced by the specified path. |
static GetExtension(const String&) | Returns the extension of the file referenced by the specified path. |
static GetFileName(const String&) | Returns the name of the file referenced by the specified path. |
static GetFileNameWithoutExtension(const String&) | Returns the name without extension of the file referenced by the specified path. |
static GetFullPath(const String&) | Converts the specified path into absolute path. |
static GetInvalidFileNameChars() | Returns an array containing characters that are not allowed in the names of files. |
static GetInvalidPathChars() | Returns an array containing characters that are not allowed in path names. |
static GetPathRoot(const String&) | Returns the root directory of the specified path. |
static GetRandomFileName() | Returns a randomly generated file name. |
static GetTempFileName_() | Creates a new file with a unique name and returns a full path to it. |
static GetTempFileNameSafe() | Creates a new file with a unique name and returns a full path to it. Is a synonym of GetTempFileName_() method. |
static GetTempPath() | Returns the path of the current user’s temporary directory. |
static HasExtension(const String&) | Determines if the specified path references a file with extension. |
static IsPathRooted(const String&) | Determines if the specified path contains a root. |
static NormalizePath(const String&) | Normalizes the specified path. |
static ToBoost(const String&) | Returns an instance of boost::filesystem::path class that represents the specified path. |
static ToString(const boost::filesystem::path&) | Returns a string representation of the specified Boost’s path object. |
Fields
Field | Description |
---|---|
static AltDirectorySeparatorChar | An alternate character used to separate directory levels in a path. |
static DirectorySeparatorChar | A character used to separate directory levels in a path. |
static PathSeparator | A separator character used to separate path strings in environment variables. |
static VolumeSeparatorChar | A volume separator character. |
Remarks
#include "system/io/path.h"
#include <iostream>
int main()
{
using namespace System::IO;
// Generate a random filename.
auto filename = Path::GetRandomFileName();
// Print information about file name.
std::cout <<
"Filename: " << Path::GetFileName(filename) << std::endl <<
"Filename w/o an extension: " << Path::GetFileNameWithoutExtension(filename) << std::endl <<
"Extension: " << Path::GetExtension(filename) << std::endl;
return 0;
}
/*
This code example produces the following output:
Filename: qhuzkyqv.y6p
Filename w/o an extension: qhuzkyqv
Extension: .y6p
*/
See Also
- Namespace System::IO
- Library Aspose.PDF for C++