"Feldman Alex" <ut*****@mail.ru> wrote in message
news:ec**************@TK2MSFTNGP15.phx.gbl...
Well , I'll describe a full task.
I'm writing a install application, and I need to know that the user have
the
privileges to install/write to program files.
Thank you
Alex
By default only administrators and power users have write access privileges
to "Program Files", so you could also check group membership for the current
user.
Something like this should do...
AppDomain ad = Thread.GetDomain();
ad.SetPrincipalPolicy(PrincipalPolicy.WindowsPrinc ipal);
WindowsPrincipal user = (WindowsPrincipal)Thread.CurrentPrincipal;
if(user.IsInRole(WindowsBuiltInRole.Administrator) ||
user.IsInRole(WindowsBuiltInRole.Administrator))
{
// Ok, user is power user or administrator
..
}
else
// Non privileged user, not ok to continue...
Another way to determine the access privileges to a folder, is by creating a
dummy file into the folder, if it fails, it's because the user has no write
access privileges.
Willy.