是否有System.IO.DirectoryInfo.Exists任何替代 [英] Is there any alternative for System.IO.DirectoryInfo.Exists

查看:355
本文介绍了是否有System.IO.DirectoryInfo.Exists任何替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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路径:
http://www.mediafire.com/?77ae4ratoqa7s4b

Try this class I made to connect to UNC paths: http://www.mediafire.com/?77ae4ratoqa7s4b

这篇关于是否有System.IO.DirectoryInfo.Exists任何替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆