2

I want to make a library that (among other things) parses UNC paths, but I don't fully understand the grammar.

Common example is: \\server\share\path

Are all of those required for a valid file path? I can navigate to \\server (without share) using Windows Explorer, but I assume it is using some share discovery protocol, not something filesystem APIs understand — is this right?

Andrey Shchekin
  • 21,101
  • 19
  • 94
  • 162
  • 1
    You're right, Explorer under the hood invokes [NetShareEnum](https://msdn.microsoft.com/en-us/library/windows/desktop/bb525387%28v=vs.85%29.aspx) to show shares on given server (and you see them as _folders_) but valid UNC is always \\server\share – Adriano Repetti Jan 27 '15 at 09:55

1 Answers1

5

You are correct. A UNC path is required to have share name component.

Quoting MSDN:

UNC = \\<hostname>\<sharename>[\<objectname>]*

The <hostname>, <sharename>, and <objectname> are referred to as "pathname components" or "path components". A valid UNC path consists of two or more path components.

https://msdn.microsoft.com/en-us/library/gg465305.aspx

dsi
  • 586
  • 3
  • 13