简体   繁体   中英

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:

  1. I bypass it
  2. 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?
  1. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM