问题描述
您好!
所以我有一个程序将通过网络路径发送文件。"// cpu1 / doc / biz / engine / law.text"但有时网络路径将不存在,而这将通过设计发生。因此,如果它不存在,它将做其他事情。我尝试了ping方法,但是会出现"无法找到主机名"的错误。我没有IP地址,只有计算机名称。我可以使用try和catch,但是等待它失败需要很长时间。我需要更快的东西。所以这是我的问题。
如何检查文件路径是否合法?如果我可以使用IP地址,我会ping,如果是,则使用文件路径,如果它是假的,请使用另一种方式。
谢谢!
鲁迪
Hello!
So I have a program that will send files via a network path."//cpu1/doc/biz/engine/law.text" But sometimes the network path will not exists, and that will happen by design. So if it doesn't exists, it will do something else. I tried the ping method, but it will error out with"Can't find host name". I don't have the IP address, only the computer name. I can use a try and catch, but it takes to long to wait for it to fail. I need something faster. So here is my question.
How can I check if a file path is legit? If I could use a IP address, I would just ping, if it true, use file path, if it's false, use the other way.
Thanks!
Rudy
推荐答案
If My.Computer.FileSystem.DirectoryExists
这样会很好,但是。 ..这很慢。我在医疗网络上,有40-50个工作站。确认文件夹是否存在大约需要15秒。有更快的方法吗?寻找大约2秒的延迟。
鲁迪
That will work well, but...
It's slow. I'm on a med network, 40-50 workstations. It takes about 15 seconds to confirm if the folder is there. Is there a faster way to do this? Looking for about a 2 second delay.
Rudy
这篇关于检查网络路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!