Overriding MAX_PATH


  1. Posts : 8
    Windows 7 Home Premium 64-bit
       #1

    Overriding MAX_PATH


    MAX_PATH is the 260 character limit Windows places on file paths. Apparently the NTFS file path limit is 32,767 characters, and since Windows uses that file system, I'm not sure what the massive restriction is for. Whenever I transfer files between hard drives of different file systems, this bloody MAX_PATH variable seems to happily get in the way, if only by a few characters. And to make matters worse, although Windows tells you about the names of the several hundred or so files that didn't quite make the transfer due to their paths being over 260 characters, it doesn't have the courtesy to tell you where exactly those files are.

    Since I expect I will continue transferring files in the near future, I have started taking a look at what is out there to override MAX_PATH. So far I have heard of Robocopy and I shall have a more in-depth look at it soon. I expect that there are also other solutions out there and that people here have attempted them, so before I commit too much to one solution that might not necessarily be the best one, it would be great to hear of any viable alternatives. Ideally there would be something that could be done "in-house", i.e. without having to rely on third-party software, to override MAX_PATH, but I'm not expecting miracles.

    Also, if anyone knows of any way to obtain a record of the paths of any files that encountered errors during transfers and thereby possibly didn't get transferred, your input on this would also be appreciated.

    Thank you for any help.
      My Computer


  2. Posts : 8
    Windows 7 Home Premium 64-bit
    Thread Starter
       #2

    logicearth said:
    Just use Robocopy as it was designed for what you want. Its built into Windows 7 so its not third-party well in terms of Windows. Furthermore, the 255 limit is an NTFS limit. I don't know where you got 32,767 but that is not it.
    That's what I thought, but some people on Wikipedia seem to think otherwise. Best not to use an encyclopedia run by the public, as they say.

    It's great that Robocopy is built in. I'll try it out after my current transfer is finished.
      My Computer


  3. Posts : 5,642
    Windows 10 Pro (x64)
       #3

    Misunderstanding on my part in the first post, however it still stands, use robocopy.

    This is probably the infromation that you want:
    Naming Files, Paths, and Namespaces (Windows)
    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. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string<NUL>" where "<NUL>" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

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

    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.
      My Computer


  4. Posts : 2,468
    Windows 7 Ultimate x64
       #4

    MAX_PATH isn't a parameter you can modify with some obscure registry technique, but rather is a constant defined in the Win32API C header files. The value comes from a limitation in the Windows API itself, as many file-handling functions take this value as the maximum allowable path length, so further folders would be truncated and programs react by preventing generating them in the first place. While the NTFS filesystem does allow longer paths, Windows itself cannot handle them correctly sometimes (I guess for compatibility reasons).
      My Computer


  5. Posts : 2,497
    Windows 7 Pro 64 bit
       #5

    The NTFS file system has a maximum path limit of 32767 bytes. But you can only realize that if the software you are using doesn't impose a lower limit. As it turns out, many system functions and software do impose a lower limit of MAX_PATH. Changing this value is so close to impossible as to not matter.

    At this point in time Microsoft can't change the value of MAX_PATH. Doing so would break an enormous amount of existing software.

    You have 2 choices:
    1. Use file copying software, such as Robocopy, that does not have the MAX_PATH limit. This will allow you to copy files with a long path but that won't help with software that recognizes this limit.
    2. Keep path lengths within the limit.
      My Computer


  6. Posts : 8
    Windows 7 Home Premium 64-bit
    Thread Starter
       #6

    Bypass MAX_PATH using drag-and-drop?


    robocopy works, but I wish there were some way to bypass max_path from startup using built-in drag-and-drop instead of having to start a program in admin mode and double-check precise commands. It might be fine for the occasional backup but when every other move is affected it starts getting annoying.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 06:35.
Find Us