c# - Delete folder programmatically as admin -
i'm trying delete user profile folder suing c# , asp.net, when through windows ui uac prompt fine.
i wish programmatically using asp.net & c# . objective admin users launch webform , remotely on workstation i'm getting permission errors. (im running visual studio admin in debugging environment delete local users)
{"access path 'c:\users\nzsp2013admin\appdata\local\microsoft\windows\application ..... denied."}
code:
var dir = new directoryinfo("c:\users\nzsp2013admin");
dir.attributes = dir.attributes & ~fileattributes.readonly;
dir.delete(true); // true => recursive delete
this has permissions configured in iis.
every asp.net application run in iis run using identity can managed in application pools
section in iis manager
.
by default, each application pool
created (including default one) have permissions within limited scope.
if i'm honest, phrase application pool
makes things sound more complicated are. application pool identity 1 use sign on pc, , in case identity normal user permissions attempting perform action requires set of higher permissions.
to resolve this, open iis.
- click on application pools
- select application pool web application running under
- click on advanced settings
- click on identity , select custom identity
- enter credentials of account has administrative privileges.
however, have warn you opening wide range of security concerns , there alternatives such adding explicit permissions specific directories include identity asp.net application running from.
Comments
Post a Comment