0

What causes invalid characters (\\?\) to appear before a file path only in certain folders?

Invalid file path:

\\?\D:\computerfiles...

The files with the invalid path cannot be opened in the original folder.

The \\?\ characters only appear for some files when in the original location, but they do NOT appear when the file is copied to a different folder.

I only see this when I find a file that will NOT open (such as an image) and I check the Properties to detect the invalid prefix

Also, how can I locate all paths with an invalid prefix?

bobkush
  • 390
  • 2
    How are you seeing this? – Moab Feb 04 '20 at 01:10
  • I only see this when I find a file that will NOT open (such as an image) and I check the Properties to detect the invalid prefix. – bobkush Feb 04 '20 at 01:17
  • Do the file names have an extra . (dot) in the name? – Moab Feb 04 '20 at 01:24
  • No - the file path and name are perfect - the file works correctly when copied to a different location (outside of the original folder) so the path and filename are valid. Its only the invalid PREFIX that has the problem. To make it more difficult - I can only get the invalid PREFIX to display in the Properties > Location field. This invalid PREFIX does not show up in any other listing of the path. – bobkush Feb 04 '20 at 01:37
  • 1
    Googling says it could be a permissions issue or a file association issue, never seen this problem myself, unusual. – Moab Feb 04 '20 at 01:39
  • Try renaming the file, be sure there are no invalid characters. – Moab Feb 04 '20 at 01:46
  • You cant rename the file as long as the invalid PREFIX is in the file path - the file is NOT recognized by DOS or FILE EXPLORER – bobkush Feb 04 '20 at 02:47

1 Answers1

3

That’s not an illegal character. It’s a signal for Windows to turn off path mangling. It allows you to have paths longer than MAX_PATH.

As per Naming Files, Paths, and Namespaces:

File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections.

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".

It appears Windows Explorer was at some point enabled to access long paths. In the process, you can see the following in the “Location” field on a file’s/folder’s property page:

  1. The “regular” path, if short enough
  2. The 8.3 names path (something like C:\WHATEV~1\...), if 8.3 names exist on this file system and if short enough
  3. The extended-length path otherwise

tl;dr: Your path is too long.

Daniel B
  • 62,883
  • Then why does the error appear? So it allows longer paths but it causes problems when it does? – Moab Feb 04 '20 at 13:41
  • The OP unfortunately failed to mention where he is seeing these paths. I’m not aware of any GUI location where Windows would expose paths like that. // Ah, no I’ve got it. – Daniel B Feb 04 '20 at 14:06
  • "enabled to access long paths" is this possible and how? – Moab Feb 04 '20 at 14:16
  • ? I’m referring to Windows’ “natural state”. I have Windows 10 1909 and did nothing but create nested folders until I could reproduce what the OP is seeing. I think Windows 7 did not have this. I’ll have to verify later. – Daniel B Feb 04 '20 at 15:24
  • Thanks Daniel. First time I ever saw this issue. – Moab Feb 04 '20 at 16:15