问题描述
的 System.IO.DirectoryInfo.Exists
总是返回false,如果我给一个UNC这样的 \\\\ 192.168.0.33 \\其他(F )
。
The System.IO.DirectoryInfo.Exists
always return false if i am giving a UNC like this \\192.168.0.33\Others (F)
.
和它,只有当我从安装的应用程序运行时,否则,如果路径是真的,那将返回true。
and it occurs only when I run from the installed application, otherwise it will return true if the path is true.
推荐答案
要访问UNC文件,你需要先提供凭据,并打开网络共享的连接连接到网络位置,之后可以运行的DirectoryInfo。存在
To access UNC file, you need to first connect to the network location by providing credentials and opening the connection to the network share, after that you can run DirectoryInfo.Exists
。看看P / Invoke来WNetAddConnection2 / NetUseAdd并通过用户名/密码 - 那么你应该能够访问该文件/文件夹的信息。
Look into P/Invoke to WNetAddConnection2 / NetUseAdd and pass the username/password- then you should be able to access the file / folder info.
编辑:
试试这个班我做了连接到UNC路径:
Try this class I made to connect to UNC paths:http://www.mediafire.com/?77ae4ratoqa7s4b
这篇关于是否有System.IO.DirectoryInfo.Exists任何替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!