Path
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 String ChangeExtension(const String&, const String&) | Changes the extension in the specified file path. |
static void 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 String Combine(const ArrayPtr<String>&) | Combines the specified path segments into a single path inserting directory separator characters between the segments if necessary. |
static String Combine(const String&, const String&) | Combines two specified path segments into a single path inserting directory separator character between the segments if necessary. |
static String 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 String 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 String GetDirectoryName(const String&) | Returns the name of the directory referenced by the specified path. |
static String GetExtension(const String&) | Returns the extension of the file referenced by the specified path. |
static String GetFileName(const String&) | Returns the name of the file referenced by the specified path. |
static String GetFileNameWithoutExtension(const String&) | Returns the name without extension of the file referenced by the specified path. |
static String GetFullPath(const String&) | Converts the specified path into absolute path. |
static ArrayPtr<char_t> GetInvalidFileNameChars() | Returns an array containing characters that are not allowed in the names of files. |
static ArrayPtr<char_t> GetInvalidPathChars() | Returns an array containing characters that are not allowed in path names. |
static String GetPathRoot(const String&) | Returns the root directory of the specified path. |
static String GetRandomFileName() | Returns a randomly generated file name. |
static String GetTempFileName_() | Creates a new file with a unique name and returns a full path to it. |
static String GetTempFileNameSafe() | Creates a new file with a unique name and returns a full path to it. Is a synonym of GetTempFileName_() method. |
static String GetTempPath() | Returns the path of the current user’s temporary directory. |
static bool HasExtension(const String&) | Determines if the specified path references a file with extension. |
static bool IsPathRooted(const String&) | Determines if the specified path contains a root. |
static String NormalizePath(const String&) | Normalizes the specified path. |
static boost::filesystem::path ToBoost(const String&) | Returns an instance of boost::filesystem::path class that represents the specified path. |
static String 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.Slides