转自:http://blog.163.com/sdzhangyuyin%40126/blog/static/138413748201461193938952/
- 判断文件夹是不是存在
bool isDirExist(QString filename,QString path = “”);//声明
bool MainWindow::isDirExist(QString filename, QString path)//定义
{
QFile mFile(path+"./"+filename);
if(mFile.exists())
{
return true;
}
return false;
} - 判断文件是不是存在
#include
代码
QFile file("./john.txt");
if (file.exists()){
QMessageBox::information(this,“测试”,“文件存在”);
}else{
QMessageBox::critical(this,“测试”,“文件不存在”);
};