Access to the path is denied
You need to find out from the application pool for the website what is the identity it is running under (by default this is Application Pool Identity
) and grant that the correct permissions.
.NET Directory.Move results in Access to path is denied with network paths
There are a number of things that could be causing it to deny access and it would be hard to point you in the right direction without seeing your code. But here are 2 scenarios that might help you.
Scenario 1 - The filepath you are using is in the wrong format, Usually I have had a access denied because the format of the network filepath was actually wrong. I would recommend looking up examples of how you should pass the filepath. Also have a talk with your network engineers and ask them about the rights that have been setup for that filepath.
Scenario 2 - You might be passing a filepath when you also need to specify a name. Now I dont have all the details but I also had issues in the past using the Directory.Move function where I actually had to specify a filename to move it to. You do this by just adding the file and extension to the end of the target path to copy to.
If you could post some more information I might be able to point you in the right direction but this is what I can think of for now. I hope this works for you or atleast brings you closer to an answer. Good luck!
*Edit: It looks like I am wrong on the scenarios, Have a look at this link Can you move a file/folder across a network share in .NET?
You will have to first manually create the filepath and then copy all the files into the new filepath you have created. It seems like Directory.Move has problems when different machines are used.
Exception Folder: Access to the Path is denied
You could check the permissions before write the file with richardwiden's answer : Checking for directory and file write permissions in .NET
Or you could use try catch
in your WriteTree()
function to ignore the UnauthorizedAccessException
exception like :
try {
writer.WriteAttributeString("name", info.Name);
[...]
} catch (Exception ex) {
// If is a permission error, ignore exception
if (ex is UnauthorizedAccessException)
return size;
// custom error log
string errorMsg = string.Format("Exception Folder : {0}, Error : {1}", info.FullName, ex.Message);
Console.WriteLine(errorMsg);
writer.WriteElementString("Error", errorMsg);
}
Related Topics
Accessing UI (Main) Thread Safely in Wpf
How to Validate Console Input as Integers
When to Dispose Cancellationtokensource
Xaml Binding Not Working on Dependency Property
Calling a Method Every X Minutes
Get Mime Type from Filename Extension
Adding Http Headers to Httpclient
How to Call the 'Base Implementation' of an Overridden Virtual Method
How to Add a Blend Behavior in a Style Setter
How to Show the "Paste JSON Class" in Visual Studio 2012 When Clicking on Paste Special
"A Project with an Output Type of Class Library Cannot Be Started Directly"
Why Is a Dictionary "Not Ordered"
Using Excel Oledb to Get Sheet Names in Sheet Order
Single Controller with Multiple Get Methods in ASP.NET Web API