How to open a UAC window to create a new file in C #

System.IO.FileMode.Create 

Indicates 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 the disk and you need additional privileges, how to get them?

What I mean - because in Windows Vista and Windows 7 there is UAC - User Account Control, how can I:

  • I go around him
  • If it cannot be bypassed, then how can I ask the user to click “Yes / No prompts” that appears through the UAC window? A.
+4
source share
2 answers
  • In the application manifest, set

    Level = "requireAdministrator"

in the requestedExecutionLevel element. The user must raise before launching the application, but will not be requested again. 2. I’m sure that you can’t control what the popup will say if that’s what you mean. Can a tooltip appear in a tooltip or (ugh) a preliminary popup? Remember to put a screen symbol on a button or something that triggers an action!

See: http://msdn.microsoft.com/en-us/library/bb756929.aspx

Edit: fixed syntax for writing manifest. Also, remember that this is not a recommended or approved way to do something. In general, try working with UAC, not against it.

+1
source

Using UAC is a process level issue. The whole process must be elevated to perform such an action. A good document that explains UAC and how to use it can be found on CodeProject .

+1
source

Source: https://habr.com/ru/post/1344714/


All Articles