I have a windows forms application which serves as a sort of administrative module for an ASP.NET web application. The web application serves multiple countries, and folders are created when new countries are added to the application data.
Unfortunately on the newly added countries I run into an exception with the web application when I go and try to write files in the folders:
System.UnauthorizedAccessException: Access to the path 'C:\...' is denied.
With the web application using ASP.NET impersonation, it's obvious that the default IIS user (MACHINENAME\IUSR_MACHINENAME) has no permissions to write into the folder.
How do I grant permission the the default IIS user upon folder creation?
I understand that
System.IO.Directory.CreateDirectory(string path, DirectorySecurity directorySecurity)
should do this, but I don't understand how to specify the log on name on the DirectorySecurity
object.