繁体   English   中英

如何从C#访问ac $资源上的文件

[英]How do I access files on a c$ resource from C#

我正在使用这样的示例:

System.IO.File.Copy("\\host\c$\folder\file.end", "c:\file.end", true);

但是我只得到带有描述的DirectoryNotFoundException

找不到路径'\\ host \\ c $ \\ folder \\ file.end'的一部分

我要做什么才能访问DRIVE $资源上的文件? 我在计算机上具有管理特权。

尝试使用逐字字符串作为路径

System.IO.File.Copy(@"\\host\c$\folder\file.end", @"c:\file.end", true);

或逃脱斜线

System.IO.File.Copy("\\\\host\\c$\\folder\\file.end", "c:\\file.end", true);

尝试:

System.IO.File.Copy(@"\\host\c$\folder\file.end", @"c:\file.end", true);

因为从异常中可以看到,路径的格式不正确。 您需要转义\\符号。

尝试

System.IO.File.Copy(@"\\host\c$\folder\file.end", @"c:\file.end", true);

强制使用字符串文字。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM