网络 C# 上另一台服务器上的引用路径
Reference Path On Another Server on Network C#
我在尝试引用与我的应用程序位于同一网络的另一个 drive\path 时遇到问题。
string LocationPath = "\servername\F$\FirstDirectory\SecondDirectory\filename.txt";
我想使用 streamreader 来捕获此文件的内容,但似乎无法访问它。这是我在文件资源管理器中引用目录的方式,如何在 C# 中完成?
感谢任何意见!
您需要转义反斜杠:
string LocationPath = "\\servername\F$\FirstDirectory\SecondDirectory\filename.txt";
或使用逐字字符串:
string LocationPath = @"\servername\F$\FirstDirectory\SecondDirectory\filename.txt";
我在尝试引用与我的应用程序位于同一网络的另一个 drive\path 时遇到问题。
string LocationPath = "\servername\F$\FirstDirectory\SecondDirectory\filename.txt";
我想使用 streamreader 来捕获此文件的内容,但似乎无法访问它。这是我在文件资源管理器中引用目录的方式,如何在 C# 中完成?
感谢任何意见!
您需要转义反斜杠:
string LocationPath = "\\servername\F$\FirstDirectory\SecondDirectory\filename.txt";
或使用逐字字符串:
string LocationPath = @"\servername\F$\FirstDirectory\SecondDirectory\filename.txt";