How to bring up the UAC Window for New File Creation in C#
System.IO.FileMode.Create
Specifies开发者_开发知识库 that the operating system should create a new file. If the file already exists, it will be overwritten.
But suppose i do not have access to a drive and need additional priviliedges, how do i get them?
What i mean is - as Windows Vista and Windows 7 have UAC
- User Account Control, how can:
- I bypass it
- If it cant be bypassed then how can i ask the user to Click on Yes/No Prompt which pops up via the UAC window?
In the application manifest, set
level="requireAdministrator"
in the requestedExecutionLevel
element.
The user must elevate before running the application, but will not be prompted again.
2. I'm pretty sure you can't control what the popup will say, if that is what you mean. Maybe display a hint in a tooltip or (ugh) a pre-popup? Don't forget to put a shield symbol on the button or whatever that launches the action!
See: http://msdn.microsoft.com/en-us/library/bb756929.aspx
Edit: corrected syntax for manifest entry. Also, mind this is not the recommended or endorsed way of doing things. In general, try to work with UAC, not against it.
Using UAC is a process level issue. The entire process would need to be elevated in order to perform such an action. A good document that does some explaining of UAC and how to use it can be found on CodeProject.
精彩评论