Sadique
Sadique

Reputation: 22823

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?

Upvotes: 4

Views: 278

Answers (2)

Kimberly
Kimberly

Reputation: 2697

  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.

Upvotes: 1

Bob Wintemberg
Bob Wintemberg

Reputation: 3252

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.

Upvotes: 1

Related Questions