Why does the 260 character path length limit exist in Windows?

后端 未结 11 968
孤城傲影
孤城傲影 2020-11-22 03:18

I have come up against this problem a few times at inopportune moments:

  • Trying to work on open source Java projects with deep paths
  • Storing deep Fitne
11条回答
  •  名媛妹妹
    2020-11-22 03:35

    This is not strictly true as the NTFS filesystem supports paths up to 32k characters. You can use the win32 api and "\\?\" prefix the path to use greater than 260 characters.

    A detailed explanation of long path from the .Net BCL team blog.
    A small excerpt highlights the issue with long paths

    Another concern is inconsistent behavior that would result by exposing long path support. Long paths with the \\?\ prefix can be used in most of the file-related Windows APIs, but not all Windows APIs. For example, LoadLibrary, which maps a module into the address of the calling process, fails if the file name is longer than MAX_PATH. So this means MoveFile will let you move a DLL to a location such that its path is longer than 260 characters, but when you try to load the DLL, it would fail. There are similar examples throughout the Windows APIs; some workarounds exist, but they are on a case-by-case basis.

提交回复
热议问题