I am having a problem where I am trying to delete my file but I get an exception.
if (result == \"Success\")
{
if (FileUpload.HasFile)
{
t
same issue for me too, I was pointing the folder instead of file.
so make sure in path, give path+filename
System.IO.File.WriteAllBytes("path", bytearray);
I have also faced this issue when my window service started throwing the exception
System.UnauthorizedAccessException: Access to the path "C:\\Order\\Media
44aa4857-3bac-4a18-a307-820450361662.mp4" is denied.
So as a solution, I checked the user account associated with my service, as shown in below screen capture
So in my case it was NETWORK SERVICE
And then went to the folder properties to check if the associated user account also exists under their permission tab. It was missing in my case and when I added it and it fixed my issue.
For more information please check the below screen capture
You need to modify the privileges of the folder you're trying to delete from/save to. Right-click on the containing folder and use the Security tab to permit modify rights for the user your application runs under.
I had the same problem on a newly moved website on a shared server. Solved through the web host panel (DotNetPanel) setting true the "allow write permissions". So if you are in a shared server before reviewing all code worth taking a look at the server configuration and could save you a lot of time.
When a user tries to connect to your Web site, IIS assigns the connection to the IUSER_ComputerName account, where ComputerName is the name of the server on which IIS is running. By default, the IUSER_ComputerName account is a member of the Guests group. This group has security restrictions. Try to grand access to IUSER_ComputerName to that folder
Here is very good described answer about IIS security
Hope this helps
If this is an IIS website that is having the problem, check the Identity property of the advanced settings for the application pool that the site or application uses. You may find that it is set to ApplicationPoolIdentity, and in that case then this is the user that will have to have access to the path.
Or you can go old style and simply set the Identity to Network Service, and give the Network Service user access to the path.