473,835 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Directory.Exist s for UNC path is sloowwwwww

css
When I call Directory.Exist s for a UNC path like below...

if (Directory.Exis ts(@\\SomeServe r\C) == false)
{
....
}

and that server does not exist on the connected network, it takes around a
minute to return from the call which properly returns false.

Is there a faster way to determine if a directory or server exists on the
network?


Dec 22 '05 #1
4 15100
When you try to access remote server, network redirector tries to get the
address of the server. It issues DNS query. This process takes a while...

AFAIK there can be several solutions:
- if you know the IP address of the server, try to connect to it on 135-139
( for UNC )
- if you know the IP substitue it into the UNC path.
- if you do not know the IP try to resolve it manually using Dns.Resolve (
..NET 1.0 - 1.1 )
or GetHostEntry ( .NET 2.0 )

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"css" <id************ @forgetit.com> wrote in message
news:96******** *************** ***********@mic rosoft.com...
When I call Directory.Exist s for a UNC path like below...

if (Directory.Exis ts(@\\SomeServe r\C) == false)
{
....
}

and that server does not exist on the connected network, it takes around a
minute to return from the call which properly returns false.

Is there a faster way to determine if a directory or server exists on the
network?

Dec 22 '05 #2
css
Vadym,

I don't know the IP. If I use or GetHostEntry() it resolves to a name
without throwing an exception even if the server doesn't exist! If I put

a legit name like:

GetHostEntry("\ \MyLocalMachine Name")

it returns "MyLocalMachine Name.hilton.com " but the IP is 0.0.0.1. (Which is
incorrect I am using a wirless connection at the Hilton hotel and the DHCP
address is 10.252.1.100).

If I use an illegit name, like
GetHostEntry("\ \VADYM")

it returns "VADYM.hilton.c om" and the IP is also 0.0.0.1.
Am I missing something?

Dec 22 '05 #3
GetHostEntry returns the list of ips, did you check the whole list?
smth like

IPHostEntry host;
host = Dns.GetHostEntr y(hostname);

Console.WriteLi ne("GetHostEntr y({0}) returns:", hostname);

foreach (IPAddress ip in host.AddressLis t)
{
Console.WriteLi ne(" {0}", ip);
}

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"css" <id************ @forgetit.com> wrote in message
news:2F******** *************** ***********@mic rosoft.com...
Vadym,

I don't know the IP. If I use or GetHostEntry() it resolves to a name
without throwing an exception even if the server doesn't exist! If I put

a legit name like:

GetHostEntry("\ \MyLocalMachine Name")

it returns "MyLocalMachine Name.hilton.com " but the IP is 0.0.0.1. (Which
is
incorrect I am using a wirless connection at the Hilton hotel and the DHCP
address is 10.252.1.100).

If I use an illegit name, like
GetHostEntry("\ \VADYM")

it returns "VADYM.hilton.c om" and the IP is also 0.0.0.1.
Am I missing something?

Dec 23 '05 #4
Why are you trying this for a path (server) that doesn't exists in the first
place? Why not ping the server before trying to connect to a remote share
exposed by the server?

Willy.
"css" <id************ @forgetit.com> wrote in message
news:96******** *************** ***********@mic rosoft.com...
When I call Directory.Exist s for a UNC path like below...

if (Directory.Exis ts(@\\SomeServe r\C) == false)
{
....
}

and that server does not exist on the connected network, it takes around a
minute to return from the call which properly returns false.

Is there a faster way to determine if a directory or server exists on the
network?

Dec 24 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
24039
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked tables in the database where the code resides. If we move the database with the data tables to a new directory, the links are no longer valid. I tried to update the links by changing the Connect property and refreshing: Set td = db.TableDefs(0)...
11
6611
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
1
4019
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the live databases on the network. Is there a way, via code, when I get back in-house from being on the road to click a button, and select the backends I want to link to? I would want to delete all the current links and link to the "live"
4
3714
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 Directory.GetFileSystemEntries(path), but I would like to know how to put this together, knowing which entry is a Subdirectory and which entry is a file, and make a recursive list of the Directory structure below a specific path - - -
18
4365
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't get it to upload a file to the FTP server. I just get a "Cannot connect to remote server" error after this TRY: s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
6
1988
by: Sigmathaar | last post by:
Hi, while making an XML parser for the creation of an entire directory list I got this problem and I'm having trouble solving it. The program (not yet written) goes through an XML Schema Instance to create some directories (about 5000). While creating the directories the XML file that I'm parsing is alphabetically ordered not hierarchically and I can't allow the program to stock the path names for each brach on the directory tree. The...
23
2448
by: **Developer** | last post by:
Is there an easy way to copies all files in a directory into another directory? What about coping subdirectories too? Thanks in advance for any info
5
6782
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would cause. If I could create a large file that could be encrypted, and maybe add files to it by appending them and putting in some kind of delimiter between files, maybe a homemade version of truecrypt could be constructed. Any idea what it...
0
2153
by: nagashree | last post by:
Hi, i want to compress the file or directory i am able to do that can anybody help me to decompress the file when i double click on the zipped file i am getting the error message as compressed(zipped) folder is invalid or corrupted. I am using VB.NET .Please help me out in this regard...Thank you in advance. Here is the code for that. Public Class clsZip
0
10523
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10560
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10233
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9345
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7766
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5804
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3088
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.