qtvisual-studio-2019visual-studio-debugginguacqfile

QT Debugging QFile::remove() Windows 10 MSVS 2019


I am working on a QT application that has to communicate with a few Windows-utilities. The result of these utilities are a couple of “production-files” that should be listed in a “filenames-txt-file” for further use.

The production of such a “filenames-txt-file” with the list of “production-files” is done with QT using QFileInfo.
Sometimes an old “filenames-txt-file” already exists in the working-directory and should be removed before it can be created with the new results.

Here is the problem:
QFile::remove("somefile") does not work while debugging.
It works fine, when I run the Exe in the debug-folder outside MSVS,
and it works fine running the release version.

While debugging, I get this messages:

if (QFile::exists(filenameFull)) {
    QFile f (filenameFull);     
    qDebug() << f.remove(filenameFull);     // returns false
    qDebug() << f.errorString();            // returns “unknown error”
}

I elevated Microsoft Visual Studio 2019 to run as administrator.
I did set the UAC execution level to “highestAvailable”.
Is anything else needed to make this code working while debugging?


Solution

  • Solved thanks to @hyde. The issue was indeed that filenameFull was opened all the time.
    Not in the code itself, but in the Configuration Properties -> Debugging -> Command Arguments
    It was hanging there from an earlier stage in the coding process.
    It explains as well why running the EXE outside the debugging-process was running fine.
    Lesson: keep my coding steps clear at all times....
    Thanks for getting me back on track.