How do I turn off path limit in Windows 10?

Issue:

How to change the default 256 character path length limitation [MAX_PATH] in Windows 10.

Environment:

Windows 10 [1607] and newer versions.

Solution:

Starting in Windows 10 [Version 1607], the MAX_PATH limitations have been removed from Common Win32 file and directory functions. To use the new extended path behavior, you must

opt-in by using a registry key change

.

Warning!
Problems caused by improperly editing the Windows registry could render your computer operating system unusable. Microsoft provides a wealth of critical information that you need to know about the registry in the Microsoft Knowledge Base. Use the Microsoft Registry Editor only at your own risk and only after backing up the registry as outlined for your operating system in the Microsoft article How to back up and restore the registry in Windows and in the related solution How to back up the system registry. Additional information about the registry is also contained in the Help topics in the Microsoft Registry Editor.

To enable the long path behavior in Windows 10:

  1. Go to Windows Start and type REGEDIT.
  2. Choose the Registry Editor.
  3. In the Registry Editor, navigate to the following location: at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem.
  4. Select the entry named: LongPathsEnabled. 

Note: If the registry key does not exist, the entry can also be added by doing the following:

  1. With the FileSystem folder selected, right-click in the empty space of the Name column where the registry keys are located.
  2. Select New.
  3. Choose the DWORD [32-bit] Value.

  1. Right-click the newly added key and choose Rename.
  2. Name the key LongPathsEnabled.
  3. Press Enter.
  1. Double-click on the LongPathsEnabled entry to open the key. 
  2. In the Value data field, enter a value of 1. This will enable to long paths option.

The registry key's value will be cached by the system [per process] after the first call to an affected Win32 file or directory function. The registry key will not be reloaded during the lifetime of the process. In order for all apps on the system to recognize the value of the key, a machine restart might be required because some processes may have started before the key was set.

Additionally, the registry key can also be controlled via the Group Policy in Computer Configuration > Administrative Templates > System > Filesystem > Enable NTFS long paths.

Products:

All Desktop Products;

Ever since Windows 95, Microsoft has only allowed file paths up to 260 characters [which, to be fair, was much nicer than the 8 character limit previously]. Now, with a registry tweak, you can exceed that amount in Windows 10.

  • Off
  • English

As pointed out by the How-To Geek, to enable long file paths, you’ll need to edit the registry. Start by following these steps:

  1. Open the Start menu and type “regedit.” Launch the application.
  2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
  3. Right-click the value “LongPathsEnabled” and select Modify.
  1. Change “Value data” from 0 to 1.
  2. Click OK.

Now you’ll be able to use much, much longer file paths. The one caveat is this may cause some compatibility problems with older 32-bit applications. If you don’t use anymore 32-bit software or simply have a strong need for very long file paths, this tweak should help you.

How to Make Windows 10 Accept File Paths Over 260 Characters | How-To Geek

Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Maximum Path Length Limitation

  • Article
  • 07/18/2022
  • 4 minutes to read

In this article

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

For example, you may hit this limitation if you are cloning a git repo that has long file names into a folder that itself has a long name.

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.

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.

There is no need to perform any Unicode normalization on path and file name strings for use by the Windows file I/O API functions because the file system treats path and file names as an opaque sequence of WCHARs. Any normalization that your application requires should be performed with this in mind, external of any calls to related Windows file I/O API functions.

When using an API to create a directory, the specified path cannot be so long that you cannot append an 8.3 file name [that is, the directory name cannot exceed MAX_PATH minus 12].

The shell and the file system have different requirements. It is possible to create a path with the Windows API that the shell user interface is not able to interpret properly.

Enable Long Paths in Windows 10, Version 1607, and Later

Starting in Windows 10, version 1607, MAX_PATH limitations have been removed from common Win32 file and directory functions. However, you must opt-in to the new behavior.

To enable the new long path behavior, both of the following conditions must be met:

  • The registry key Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled [Type: REG_DWORD] must exist and be set to 1. The key's value will be cached by the system [per process] after the first call to an affected Win32 file or directory function [see below for the list of functions]. The registry key will not be reloaded during the lifetime of the process. In order for all apps on the system to recognize the value of the key, a reboot might be required because some processes may have started before the key was set.

You can also copy this code to a .reg file which can set this for you, or use the PowerShell command from a terminal window with elevated privileges:

  • Registry [.reg] file
  • PowerShell
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"LongPathsEnabled"=dword:00000001

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

Note

This registry key can also be controlled via Group Policy at Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths.

  • The application manifest must also include the longPathAware element.

    
        
            true
        
    
    

These are the directory management functions that no longer have MAX_PATH restrictions if you opt-in to long path behavior: CreateDirectoryW, CreateDirectoryExW GetCurrentDirectoryW RemoveDirectoryW SetCurrentDirectoryW.

These are the file management functions that no longer have MAX_PATH restrictions if you opt-in to long path behavior: CopyFileW, CopyFile2, CopyFileExW, CreateFileW, CreateFile2, CreateHardLinkW, CreateSymbolicLinkW, DeleteFileW, FindFirstFileW, FindFirstFileExW, FindNextFileW, GetFileAttributesW, GetFileAttributesExW, SetFileAttributesW, GetFullPathNameW, GetLongPathNameW, MoveFileW, MoveFileExW, MoveFileWithProgressW, ReplaceFileW, SearchPathW, FindFirstFileNameW, FindNextFileNameW, FindFirstStreamW, FindNextStreamW, GetCompressedFileSizeW, GetFinalPathNameByHandleW.

How do I turn off Max path limit?

Solution:.
Go to Windows Start and type REGEDIT..
Choose the Registry Editor..
In the Registry Editor, navigate to the following location: at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem..
Select the entry named: LongPathsEnabled..

How do I get Windows 10 to accept file paths over 260 characters?

- Windows 10 Pro:.
Hit the Windows key, type gpedit. msc and press Enter..
Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem > NTFS..
Double click the Enable NTFS long paths option and enable it..

What is the file path character limit Windows 10?

In this article. 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.

Why is there a file path limit?

The 260-character path limit is due to fixed buffers in the runtime library for DOS/Windows path processing [e.g. ANSI Unicode, working directory, and DOSNT path conversion].

Chủ Đề