Hi,
I have an application that needs to create and copy files in multiple locations that can be share folder on the network. I'm using System.IO.Directory.Exists() method to determine if directory is exist before I do the work. If some machine is down (I just unplug network cable for testing) at this moment this method always returns false that what expect, but on my machine it returns almost right away and on other system it delays for 30 seconds or more.I can't figure out what can cause this and how I can resolve this problem. I'll appreciate any help.
I'm not entirely sure but I assume that directory.exists times out which is when the false return is generated. I am away from VS at the moment so I can't check but have a look if there is anyway to set this timer lower.
Alternatively, you could declare your own timer, then call Directory.Exists and check it's return value after whatever time period you think is appropriate. If it is not true then you could pretty safely assume that it isn't going to be found and axe it there.
I wouldn't use this method though if it is for anything important. There could always be a chance (slim) that there is just a delay in accessing the network which could give you a false result.