I'm using an example like this:
System.IO.File.Copy("\\host\c$\folder\file.end", "c:\file.end", true);
But I'm only getting a DirectoryNotFoundException with the description
Could not find a part of the path '\\host\\c$\\folder\\file.end'
What do I have to do to access files on a DRIVE$ resource? I have administrative privileges on the machine.
Try using a verbatim string for the path
System.IO.File.Copy(@"\\host\c$\folder\file.end", @"c:\file.end", true);
or escape the slashes
System.IO.File.Copy("\\\\host\\c$\\folder\\file.end", "c:\\file.end", true);
Try:
System.IO.File.Copy(@"\\host\c$\folder\file.end", @"c:\file.end", true);
Because as you can see from exception path is not well formatted. You need to escape \\
symbol.
Try
System.IO.File.Copy(@"\\host\c$\folder\file.end", @"c:\file.end", true);
Force a string literal.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.