Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you quickly check if a network location exists using Delphi 5? [duplicate]

Possible Duplicates:
Speed up File.Exists for non existing network shares
Faster DirectoryExists function?

We need to write text to a file on our network, but there may be a situation where that location does not exist and we need to write to another location instead. How do you check quickly that a network location exists? Attempting to write text to a location that does not exist using a 'try...except' takes a whopping 30 seconds(ish). There must be a faster way, surely?

I'd be very grateful if someone could give me some pointers please.

Thanks!

like image 727
JamesW Avatar asked Feb 28 '23 22:02

JamesW


1 Answers

For those of you interested in the answer for a Delphi context, I used the Indy component IdIcmpClient component to ping the IP, as follows:

  IdIcmpClient1.Host:= '10.0.0.999';
  try
    IdIcmpClient1.Ping();
  except
    showmessage('Not found');
  end;

You get a result in just over 3 seconds if it is not there, or almost instantly if it is.

like image 114
JamesW Avatar answered Mar 05 '23 17:03

JamesW