更快的DirectoryExists功能? [英] Faster DirectoryExists function?

查看:144
本文介绍了更快的DirectoryExists功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

DirectoryExists (const PathName : String);

检查目录是否从计算机可访问。但是,如果目录不存在,并且路径名称是网络路径,即

to check if a directory is reachable from a computer or not. But if the directory does not exist and the path name is a network path, i.e.

\\computer1\Data

该方法需要很长时间才能返回。

the method takes a very long time to return.

必须有一种更快的方式来确定网络文件夹不可访问。或者我可以配置DirectoryExists在内部使用的一些超时参数(我查看源代码,但它只是委托给在kernel32中定义的GetFileAttributes)?

There must be a faster way to determine that a network folder is not reachable. Or can I configure some timeout parameter that DirectoryExists uses internally (I looked at the source code but it just delegates to GetFileAttributes which is defined in kernel32)?

任何想法? / p>

Any ideas?

推荐答案

没有更快的方法:

当该共享不可用时,远程共享将超时。

any function accessing anything on a remote share will timeout when that share is not available.

如果超时的原因是自动断开共享,则此链接可能会帮助您: http://support.microsoft.com/default.aspx?scid=kb; [LN]; Q138365

If the cause of your timeouts is automatic disconnecting of shares, then this link may help you: http://support.microsoft.com/default.aspx?scid=kb;[LN];Q138365

如果应用程序可以在没有完成检查的情况下继续执行,那么可以将检查放在单独的线程中,并在完成后的支票,您可以在UI中更新您的状态。

If the application can continue without the completion of the check, then you can put the check in a separate thread, and upon completion of the check, you can update your status in the UI.

- jeroen

--jeroen

这篇关于更快的DirectoryExists功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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