I just encountered a strange problem and here is the solution to it. Maybe someone will help this post :-)
In short: To avoid UAC problems, use "READONLY" or "ACTION=READ" to open files when just want to read a file. I always opened a file by default in readwrite mode because I ommited the action statement. But because of readwrite, this happened to me:
For my latest project I had to create a deployment mechanism, so I created an installer project in my solution that creates a msi package. It simply installs a few executables and text config files in the program files folder.
A few days later I made an update to the project and changed a text config file, rebuild the installer and installed it to a clients machine. But the project wouldn´t work. Somehow the text config file wasn´t recognized by the program. So I opened the program files folder and looked at the text file. It was the new one. Opened it by command line. It was the new one. I put write statements in my project to see what it has read. It was the old one. But how could it a read the old one? There is the new in the folder. Doubled checked it.
When asking a colleague at work he had an idea. A compatibilty feature of Windows Vista and Windows7 (8, I don´t know) creates a virtualstore folder when you want to write a file in the program files folder. Because writing in program files was common in Windows XP and forbidden in Vista this feature stores newly written files not in C:\Program Files (x86) but in C:\Users\UserName\AppData\Local\VirtualStore\Program Files (x86). When I opened a text file in readwrite mode, Windows7 created a copy in this VirtualStore folder and used this one. Even when my installer wrote a new file in my normal program files folder there was the old one in the VirtualStore folder. And this one was opened all the time.
So, the solution was to use "open(newunit=iunit, file=filename, readonly)" instead of "open(newunit=iunit, file=filename)".