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
I was trying to use System.IO.File.OpenWrite(path)
and it did not work because I was only passing OpenWrite() a path to a directory, but it requires a path all the way to the file you want to write. So a full path including the filename.extension at the end needs to be passed into OpenWrite to avoid UnauthorizedAccessException
Check your files properties. If the read-only is checked, uncheck it. This was my personal issue with the UnauthorizedAccessException.
I also ran into this post as dealing with the same issue. Looks like the file is in use and hence not able to write to it. Though not able to figure it out, which process is using it. Signed out the other user who was logged in in that box, dont see any users who is holding it. Any quick tips regarding on how to find the same.
Thanks, Lakshay (developer)
An UnauthorizedAccessException exception is thrown when the operating system denies access because of an I/O error or a security error.
If you are attempting to access a file or registry key, make sure it is not read-only.
I got this error and solved it in just a moment. Don't know why all of my folders are read-only,I cancelled the read-only and apply it. However, it is still read-only. So I moved the file into the root folder, it works - so weird.
Be aware that if you are trying to reach a shared folder path from your code, you dont only need to give the proper permissions to the physicial folder thru the security tab. You also need to "share" the folder with the corresponding app pool user thru the Share Tab