I wrote an ASP.NET Web form that attempts to copy a file from one location to another. I am able to copy a file from server A to a different location on server A, but when I try to copy a file from server B to server A, I get an error stating that the file does not exist -- but it really does. Here is an example of the code I am using:
This looks like a problem with UNC paths. You can always check if a file exists (at least for the given path) by using File.Exists. Remember that paths must be fully qualified for remote locations.
Another problem that may arise is security, because by default, unless you're impersonating, the process accessing the files will be the ASP.NET account, and not the logged in user account. This may be causing trouble across the network if you have permissions set on the network share or file.
Dig Deeper on Win Development Resources
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ... Continue Reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers. Continue Reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.