Detect if a path is a UNC 
Author Message
 Detect if a path is a UNC

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



Mon, 23 Feb 2004 20:14:08 GMT  
 Detect if a path is a UNC
???

Why is this not adequate???

If Left(Trim(sPath)) = "\\" Then
    'it's UNC...
Else
    'it's not...
Endif

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--


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



Mon, 23 Feb 2004 23:48:32 GMT  
 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



Tue, 24 Feb 2004 01:06:13 GMT  
 Detect if a path is a UNC
seems to be the question: Is a UNC and Is path Local are two different
question since a UNC could refer to a path on the hosting machine.

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



Tue, 24 Feb 2004 19:29:44 GMT  
 Detect if a path is a UNC

Quote:
> seems to be the question: Is a UNC and Is path Local are two different
> question since a UNC could refer to a path on the hosting machine.

All UNC paths are treated by the OS as remote resources even if they refer to a share on the local
machine...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--



Tue, 24 Feb 2004 22:36:03 GMT  
 Detect if a path is a UNC
I guess my point was LOCAL has very little meaning, it is either a shared
resource (with its contingent security issues) or NOT.  Seems a lot like a
default = working = current directory - names which have very little
meaning.



Quote:


> > seems to be the question: Is a UNC and Is path Local are two different
> > question since a UNC could refer to a path on the hosting machine.

> All UNC paths are treated by the OS as remote resources even if they refer

to a share on the local
Quote:
> machine...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --



Fri, 27 Feb 2004 20:19:38 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Detect if a path is a UNC

2. Converting logical paths to UNC paths

3. Converting logical paths to UNC paths

4. Converting local path to UNC path?

5. Local path vs UNC Path

6. Help converting UNC paths to physical paths.

7. How transform path into unc-path ?

8. How to convert local path to UNC-path?

9. How to convert local path to UNC-path?

10. turning a local path into a UNC path

11. How to convert path to UNC path?

12. Problem using FileSystemObject and UNC paths

 

 
Powered by phpBB® Forum Software