QDir中mkdir和mkpath的区别!
mkdir:
原型:bool QDir::mkdir(const QString &dirName) const
Creates a sub-directory called dirName.
Returns true on success; otherwise returns false.
If the directory already exists when this function is called, it will return false.
mkpath:
原型:bool QDir::mkpath(const QString &dirPath) const
Creates the directory path dirPath.
The function will create all parent directories necessary to create the directory.
Returns true if successful; otherwise returns false.
If the path already exists when this function is called, it will return true.
区别:如果要创建的目录存在,mkdir返回false,而mkpath返回true,另外mkpath里为路径或者目录,而mkdir必须为目录!!!
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/231128.html原文链接:https://javaforall.net
