1.在处理文件名称时有时需要将可能带有“.”或“..”的相对文件名称或路径处理为标准文件名称或路径,可使用如下方法:
(1)QString QFileInfo::canonicalFilePath() const
Returns the canonical path including the file name, i.e. an absolute path without symbolic links or redundant "." or ".." elements.
If the file does not exist, canonicalFilePath() returns an empty string.
//
获得文件的标准路径
curFile
=
QFileInfo
(fileName).
canonicalFilePath();
(2) QString QFileInfo::canonicalPath() const
Returns the file's path canonical path (excluding the file name), i.e. an absolute path without symbolic links or redundant "." or ".." elements.
If the file does not exist, canonicalPath() returns an empty string.