共用方式為


CPathT Class

This class represents a path.

Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

template< typename StringType> 
class CPathT

Parameters

  • StringType
    The ATL/MFC string class to use for the path (see CStringT).

Members

Public Typedefs

Name

Description

CPathT::PCXSTR

A constant string type.

CPathT::PXSTR

A string type.

CPathT::XCHAR

A character type.

Public Constructors

Name

Description

CPathT::CPathT

The constructor for the path.

Public Methods

Name

Description

CPathT::AddBackslash

Call this method to add a backslash to the end of a string to create the correct syntax for a path.

CPathT::AddExtension

Call this method to add a file extension to a path.

CPathT::Append

Call this method to append a string to the current path.

CPathT::BuildRoot

Call this method to create a root path from a given drive number.

CPathT::Canonicalize

Call this method to convert the path to canonical form.

CPathT::Combine

Call this method to concatenate a string representing a directory name and a string representing a file path name into one path.

CPathT::CommonPrefix

Call this method to determine whether the specified path shares a common prefix with the current path.

CPathT::CompactPath

Call this method to truncate a file path to fit within a given pixel width by replacing path components with ellipses.

CPathT::CompactPathEx

Call this method to truncate a file path to fit within a given number of characters by replacing path components with ellipses.

CPathT::FileExists

Call this method to check whether the file at this path name exists.

CPathT::FindExtension

Call this method to find the position of the file extension within the path.

CPathT::FindFileName

Call this method to find the position of the file name within the path.

CPathT::GetDriveNumber

Call this method to search the path for a drive letter within the range of 'A' to 'Z' and return the corresponding drive number.

CPathT::GetExtension

Call this method to get the file extension from the path.

CPathT::IsDirectory

Call this method to check whether the path is a valid directory.

CPathT::IsFileSpec

Call this method to search a path for any path-delimiting characters (for example, ':' or '\' ). If there are no path-delimiting characters present, the path is considered to be a File Spec path.

CPathT::IsPrefix

Call this method to determine whether a path contains a valid prefix of the type passed by pszPrefix.

CPathT::IsRelative

Call this method to determine if the path is relative.

CPathT::IsRoot

Call this method to determine if the path is a directory root.

CPathT::IsSameRoot

Call this method to determine whether another path has a common root component with the current path.

CPathT::IsUNC

Call this method to determine whether the path is a valid UNC (universal naming convention) path for a server and share.

CPathT::IsUNCServer

Call this method to determine whether the path is a valid UNC (universal naming convention) path for a server only.

CPathT::IsUNCServerShare

Call this method to determine whether the path is a valid UNC (universal naming convention) share path, \\server\share.

CPathT::MakePretty

Call this method to convert a path to all lowercase characters to give the path a consistent appearance.

CPathT::MatchSpec

Call this method to search the path for a string containing a wildcard match type.

CPathT::QuoteSpaces

Call this method to enclose the path in quotation marks if it contains any spaces.

CPathT::RelativePathTo

Call this method to create a relative path from one file or folder to another.

CPathT::RemoveArgs

Call this method to remove any command-line arguments from the path.

CPathT::RemoveBackslash

Call this method to remove the trailing backslash from the path.

CPathT::RemoveBlanks

Call this method to remove all leading and trailing spaces from the path.

CPathT::RemoveExtension

Call this method to remove the file extension from the path, if there is one.

CPathT::RemoveFileSpec

Call this method to remove the trailing file name and backslash from the path, if it has them.

CPathT::RenameExtension

Call this method to replace the file name extension in the path with a new extension. If the file name does not contain an extension, the extension will be attached to the end of the string.

CPathT::SkipRoot

Call this method to parse a path, ignoring the drive letter or UNC server/share path parts.

CPathT::StripPath

Call this method to remove the path portion of a fully qualified path and file name.

CPathT::StripToRoot

Call this method to remove all parts of the path except for the root information.

CPathT::UnquoteSpaces

Call this method to remove quotation marks from the beginning and end of a path.

Public Operators

Name

Description

CPathT::operator const StringType &

This operator allows the object to be treated like a string.

CPathT::operator CPathT::PCXSTR

This operator allows the object to be treated like a string.

CPathT::operator StringType &

This operator allows the object to be treated like a string.

CPathT::operator +=

This operator appends a string to the path.

Public Data Members

Name

Description

CPathT::m_strPath

The path.

Remarks

CPath, CPathA, and CPathW are instantiations of CPathT defined as follows:

typedef CPathT< CString > CPath;

typedef CPathT< CStringA > CPathA;

typedef CPathT< CStringW > CPathW;

Requirements

Header: atlpath.h

See Also

Reference

CStringT Class

Other Resources

ATL Classes