简体   繁体   English

网络文件夹上的 Directory.GetFiles

[英]Directory.GetFiles on network folder

How can I get Directory.GetFiles() to check a networked folder?如何让 Directory.GetFiles() 检查网络文件夹?

I have the following line of code in my project:我的项目中有以下代码行:

string[] array2 = Directory.GetFiles(targetFolder, "*.zip");

The variable targetFolder is grabbed from my appSettings files and resembles: \\\\myNetwork\\\\Project\\\\TargetFolder\\\\变量targetFolder是从我的 appSettings 文件中获取的,类似于: \\\\myNetwork\\\\Project\\\\TargetFolder\\\\

However, when I debug my project, Directory.GetFiles() changes it to: C:\\\\myNetwork\\\\Project\\\\TargetFolder\\\\ which is incorrect and fails.但是,当我调试我的项目时, Directory.GetFiles()将其更改为: C:\\\\myNetwork\\\\Project\\\\TargetFolder\\\\这是不正确且失败的。

How can I fix this?我怎样才能解决这个问题?

Your network path should start with two slashes which are special characters, so you should use double on those as well:您的网络路径应该以两个特殊字符的斜杠开头,因此您也应该在这些斜杠上使用 double:

\\\\myNetwork\\Project\\TargetFolder

Notice the four slashes in front (which actually represent two).注意前面的四个斜线(实际上代表两个)。

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

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