stukennedy
stukennedy

Reputation: 1108

Qt QFileInfo::exists() returns true in C://Program Files

It seems that on Windows I can't write to the Program Files or Program Files (x86) directories or their sub-directories anymore.

What I don't understand is how my app is letting that happen when I'm checking the following things

QFile newfile("C://Program Files/target.rar");
QFileInfo newfileInfo("C://Program Files/target.rar");

newfile.exists(); //returns true
newfile.isWritable(); // returns true
newfileInfo.exists(); // returns true
newfileInfo.isWritable(); // returns true   

none of those should return true in Program Files. Strangely it actually proceeds to write to this non-existent file, even though nothing is there, and it produces no write errors.

Upvotes: 0

Views: 227

Answers (1)

Paul
Paul

Reputation: 13238

You may be a victim of UAC Virtualization. Check %userprofile%\AppData\Local\VirtualStore\Program Files to see whether your file is there.

Upvotes: 1

Related Questions