问题
I have an ASP.NET application running over a shared .NET server. I want to allow the current logged user to create a folder into a specific path when the application needs it. So, I'm just checking the following:
var userFolderPath = Path.Combine(Server.MapPath("~/storedphotos"), username);
if (!Directory.Exists(userFolderPath)) {
Directory.Create(userFolderPath);
}
When I run this code into my local machine it works perfectly. However, when I publish the application to that server and try to do the same, it's returning me:
"Access to the path 'xxxxxx' is denied."
I think it could be a permission issue. Once I cannot change anything at the IIS into the server or any configuration, is there a way to let the user is using my application to create the folder without problems?
回答1:
try this:
"Access to the path 'xxxxxx' is denied."
As Error says You need to assign Permissions to Folders
- Right Click Folder
- Go to Security Tab
- Click on Edit
- Click on Add
- Click on Addvance
- Find Now
- Give Permission to
IIS_IUSRS
(Full Control) - Click On OK
- Click On OK
- Click On
Full Control
in allow - Click On OK
- Again Run the Application
Note: If Above things are not working then try to give same permission to
NETWORK
,NETWORK SERVICE
Users
来源:https://stackoverflow.com/questions/26849554/createdirectory-at-server-in-a-shared-machine