I want to know if a program is running as administrator.
The user doesn't have to be administrator. I only want to know if my application has rights to edit some secured files that are editable when running as Administrator.
This will return a bool valid
using System.Security.Principal;
bool isElevated;
using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
{
WindowsPrincipal principal = new WindowsPrincipal(identity);
isElevated = principal.IsInRole(WindowsBuiltInRole.Administrator);
}