Last post Jul 24, 2008 11:56 PM by Thomas Sun – MSFT
Jul 21, 2008 05:27 PM|bfr|LINK
Is there a way to programatically set file write permissions using a custom action in a Web Setup project?
I would like to set write permissions on a file in the App_Data folder for the Web Application.
The application will just be installed in a virtual directory in the default site and run from the default anonymous user. I need to understand what account(s) need to be granted write access and if there is a way (through scripting?) to set the permissions
on the file.
Jul 24, 2008 11:56 PM|Thomas Sun – MSFT|LINK
When we deploy ASP.NET application on IIS, the accounts that runs your application might be "ASPNET" or "NETWORK SERVICE" basing on IIS version.
You can add the access control list (ACL) entries to the file for the specified account in custom action. For example:
void AddFileSecurity(string fileName,
FileSystemRights rights, AccessControlType controlType)
// Get a FileSecurity object that represents the
// current security settings.
FileSecurity fSecurity = File.GetAccessControl(fileName);
// Add the FileSystemAccessRule to the security settings.
// Set the new access settings.
For more information, see
I look forward to receiving your test results.