System.UnauthorizedAccessException while creating a file

后端 未结 3 761
遥遥无期
遥遥无期 2021-01-18 14:26

I was trying to write a code so that I could log the error messages. I am trying to name the file with the date and would like to create a new log file for each day. After g

3条回答
  •  既然无缘
    2021-01-18 14:43

    Some possible reasons:

    • your app is not running under account which is allowed to access that path/file
    • the file is being locked for writing (or maybe reading too) by some other process

    The first situation could be solved by checking under which account the process is running and verifying that the account has the appropriate rights.

    The other situation can be solved by checking if any other process is locking the file (e.g. use tools like 'WhosLocking' or 'ProcessExplorer'

提交回复
热议问题