Why is access to the path denied?

前端 未结 29 1486
刺人心
刺人心 2020-11-22 15:25

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         


        
29条回答
  •  孤城傲影
    2020-11-22 15:58

    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

提交回复
热议问题