Check if mapped network available

前端 未结 3 1815
独厮守ぢ
独厮守ぢ 2021-01-28 17:03

I am trying to have my program check is a mapped network drive is actually connected, and change the curDrive variable based on the result. It works okay, but if the drive is st

3条回答
  •  佛祖请我去吃肉
    2021-01-28 17:15

    Both show the same delay because both methods invoke the same underlying OS functionality to check for the presence of the network drive.

    The OS is giving the external resource time to be available. I don't think you can do anything except await the timeout, if you want to know for sure.

    If you know that, in your environment the OS timeout is just too long (e.g. "If it has not responded after 1 second, it will not respond), you could use a mechanism such as a timer to avoid waiting the full duration (set a 1 second timer when you start checking, if the timer fires and you still have no reply, the drive was not present).

提交回复
热议问题