How do I access files on a c$ resource from C#
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 开发者_如何学Goa 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.
精彩评论