I am so frustrated as I search the internet and cannot find solution for what I want to do...

I want my C or C++ code be able to create a file in a directory under "C:\Program Files", for example "C:\Program Files\abc\xyz.txt". This usually triggers a security confirmation like "You need to provide administrator permission..." when you do it manually on Windows vista/7. I don't mind if this attempt requires a confirmation from user to continue.

I've tried FileIOPermission with no luck. Please help me if you know the resolution. Thank you very much


7 Years
Discussion Span
Last Post by linx_mt

Code please? We can't really help much without seeing your attempt at it.

N.B.: I hope you are aware that in C/C++ you cannot write a file-path as "C:\Program Files\my\path\file.txt", because the slash "\" character is an escape character. To actually get the "\" character, you need to write "\\" instead, as so: "C:\\Program Files\\my\\path\\file.txt".


I need to create a license file (text file) in the same directory (C:\Program Files\VendorName\SoftwareName\SoftwareName.lic") as the executable. The license file will be created only once the first time user launch the program.

Because the license file is supposed to be shared among multiple users on the computer, it makes sense to make it sit in a "centralized" directory.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.