-1
我的应用程序的可执行文件驻留在somwhere/appDir/bin中。我希望它打开somwhere/appDir/data中的文件。它在Win7,Win8和Vista上运行良好,但在XP上失败。我的代码是:当执行到达src->exists()
../的路径无法在win XP和Qt上运行
QString dirPath = QCoreApplication::applicationDirPath();
QFile* src;
src = new QFile(dirPath + "/../data/file.txt");
qDebug()<<src->exists();
应用程序崩溃。当路径中没有..
时,一切正常。为什么?除了从路径字符串中剥离目录名之外,还有其他方法可以到达父目录吗?