When I try to copy an existing file from a remote computer to local with
File.Copy(
string.Format(@"\\{0}\e$\{1}", computerName, fileName),
string.Format(@"{0}\{1}\{2}", localPath, computerName, fileName),
true);
I get the exception
Could not find part of the path "\computername\e$\filename".
I checked the path and it's correct.
I don't think that is a permission problem because I can reach the file with Directory.GetFiles
and I can obtain info like file size or last writing date with FileInfo
, moreover when I execute xcopy command from cmd with the same paths in the code he copies the file successfully.
Can anyone help me to understand what I do wrong or other ways to copy file?