By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,810 Members | 1,601 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,810 IT Pros & Developers. It's quick & easy.

System.IO.Directory.Exists delays

P: 1
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.
Aug 29 '07 #1
Share this Question
Share on Google+
1 Reply


naivE
P: 12
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.
Aug 29 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.