Board index » cppbuilder » Validating a UNC path?

Validating a UNC path?


2007-03-18 10:48:39 PM
cppbuilder37
Anyone know how to determine at runtime if a UNC path spec is currently
valid? My app is sleeping for up to a minute trying to find a folder in
a UNC path that points to a volume that is offline. I'm using
DirectoryExists() for this, and this function works fine for local
volumes, but IF its pathspec is UNC and IF the target volume is not on
the network at the moment, this function takes a minute or two to time
out, and the rest of the app is waiting to execute until this function
returns. DirectoryExists() works fine for valid UNC paths:
String logpath;
logpath = "C:\\log_files\\";
if(DirectoryExists(logpath))OpenLogFile(); // this is no problem
logpath = "\\\\FILESERV\\logs\\";
if(DirectoryExists(logpath))OpenLogFile();
If FILESERV is offline, this function has to timeout before control is
passed back to your app.
Is there some alternative to DirectoryExists()?
 
 

Re:Validating a UNC path?

Mike K wrote:
Quote
Is there some alternative to DirectoryExists()?
I don't know, but you could enumerate the computers in the network, and
test if the computer the unc-path is pointing to is found in the network.
 

Re:Validating a UNC path?

Koen wrote:
Quote
I don't know, but you could enumerate the computers in the network,
How would you do that? Is there an API call for it?
 

{smallsort}

Re:Validating a UNC path?

Mike K wrote:
Quote
Koen wrote:
>I don't know, but you could enumerate the computers in the network,

How would you do that? Is there an API call for it?


groups.google.com/groups/search
3Aborland.public.cppbuilder.*&qt_s=Search+Groups
Basicly, you'll need a recursive function using WNetOpenEnum and
WNetEnumResource to retrieve the computernames.