What does the following notation mean: \\?\c:\ mean?

I recall hearing someone mention something about de-referencing a path but de-referencing wasn't explained and I don't know what it is.


Solution 1:

It's an extended length path. See MSDN: Naming Files, Paths, and Namespaces

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. [...]

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. [...] To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path".

Basically, \\?\ tells the Windows API to pass the path directly to the file system without further manipulations. In addition to extending the available length, it disables the automatic conversion of / to \ and also allows you to use the reserved file names . and ... See the article linked above for details.

Solution 2:

What does the \\?\c:\ mean?

The first part \\?\is called an extended-length path prefix. It is used get around Windows API limitations in the Maximum Path Length:

For file I/O, the "\?\" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system.

For example, if the file system supports large paths and file names, you can exceed the MAX_PATH limits that are otherwise enforced by the Windows APIs.

The second part c:\ is a reference to the root path of drive c:.

Maximum Path Length Limitation

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters.

...

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters).

To specify an extended-length path, use the "\?\" prefix. For example, "\?\D:\very long path".

Note: The maximum path of 32,767 characters is approximate, because the "\?\" prefix may be expanded to a longer string by the system at run time, and this expansion applies to the total length.

The "\?\" prefix can also be used with paths constructed according to the universal naming convention (UNC). To specify such a path using UNC, use the "\?\UNC\" prefix. For example, "\?\UNC\server\share", where "server" is the name of the computer and "share" is the name of the shared folder. These prefixes are not used as part of the path itself. They indicate that the path should be passed to the system with minimal modification, which means that you cannot use forward slashes to represent path separators, or a period to represent the current directory, or double dots to represent the parent directory. Because you cannot use the "\?\" prefix with a relative path, relative paths are always limited to a total of MAX_PATH characters.

Source Naming Files, Paths, and Namespaces