
Detect if a path is a UNC
If looking both for files and folders, drop the \.[^\\*/\?<>\|]+ from
the end of regexp. Drop part for matching local paths, port to VBS
should be straightforward (wherever doubled - drop one backslash, leaving
only one...).
function isFQfN(sFQfN) {
// Return true if passed string is in Fully Qualified file Name format
// (does NOT try to confirm if file really exists)
// will match ONLY UNC PATH: \\MyServ\MyFldr1\ ... \myfile.ext
var re = /^\\{2}(?:[^\\*/\?<>\|]+\\){2,}(?:[^\\*/\?<>\|]+\.[^\\*/\?<>\|]+)$/;
if (re.test(sFQfN)) return true; // >>>
// will match ONLY LOCAL PATH: C:\myfile.ext OR
// C:\MyFldr1\ ... \myfile.ext
re = /^[A-Za-z]:\\(?:[^\\*/\?<>\|]+\\)*(?:[^\\*/\?<>\|]+\.[^\\*/\?<>\|]+)$/;
if (re.test(sFQfN)) return true; // >>>
return false; // >>>
Quote:
}
Branimir
Quote:
> Is there an API call, or a method of the FileSystemObject that I can
> use to test if a path is a UNC?
> I don't need to know that UNC actually exists, I simply need a
> reliable way (no string parsing for \\!) to know if the path is local.
> Any ideas?
> Alastair