簡體   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