473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

System.IO.Directory.Exists delays

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
1 1814
naivE
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

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

Similar topics

1
by: Matthias Ludwig | last post by:
I'm trying to create a directory on the web server with a vb.net code: .... Dim dirName As String = "w:\filepath\images" If Not Directory.Exists(dirName) Then...
2
by: Zeno Lee | last post by:
I'm using File.Exists to test a file on my C: drive. My program was strongly named and had caspol -af run on it to allow it to run from the network. There are 3 ways I am doing this: 1) Run...
6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
4
by: Elmo Watson | last post by:
Is there a way, with the System.IO class, to do a recursive list of a directory structure? For instance, in DirectoryInfo, you have GetDirectories and GetFiles .... In Directory, you have...
5
by: rcolby | last post by:
Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of...
5
by: Philip Wagenaar | last post by:
I have a Windows Form application that monitors a directory using the System.IO.FileSystemWatcher. On the event created I run a sub that sends an xml file over http to a service. When I copy...
4
by: adamrobillard | last post by:
I am very new to vb.net and am using Visual Basic 2005 Express Edition. This is my function that essentially looks at a directory to see if it is valid: 'Local variables Dim sDirectory As...
4
by: Brandon McCombs | last post by:
Hello, From my understanding, DirectoryEntry is used to connect to Active Directory. Although this makes no sense whatsoever I accept it. The problem is how am I supposed to test whether a...
9
by: shughes | last post by:
i am not really a programmer, so i have a question on the system.io.directory.exists what i am trying to do is have a button, once this button is clicked it checks to see if the Directory...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.