vb.net directory.exists没有返回正确的值 [英] vb.net directory.exists not returning correct value

查看:355
本文介绍了vb.net directory.exists没有返回正确的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文件目录路径为 \\x\y\z (目录存在)。



当我将上述路径传递给directory.exists()方法时,它返回true



很好



现在我将路径作为 directory.exists(\\x\y\\ z)传递。它应该返回false但是这个方法返回true,即使路径不存在。



有什么建议吗?



TIA

I have a file directory path as \\x\y\z(directory exists) .

when I pass the above path to directory.exists() methods it returns true which

is fine

now I pass path as directory.exists("\\x\y\\z"). it should return false but this method returns true even though the path does not exists.

any suggestions ?

TIA

推荐答案

As 文档 [ ^ ]说:



As documentation[^] says:

MSDN写道:

如果你没有对目录的最小只读权限,Exists方法将返回 false



如果在尝试确定指定文件是否存在时发生任何错误,则Exists方法返回 false 。在引发异常的情况下会发生这种情况,例如传递带有无效字符或字符太多的文件名,磁盘失败或丢失,或者调用者没有读取文件的权限。

If you do not have at a minimum read-only permission to the directory, the Exists method will return false.

The Exists method returns false if any error occurs while trying to determine if the specified file exists. This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters, a failing or missing disk, or if the caller does not have permission to read the file.





因此,请调试程序以找出错误的位置。



So, debug your program to find out where the bug is.


这篇关于vb.net directory.exists没有返回正确的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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