How to Remove max path length limitation in Windows 10?

System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Does the above exception message seem familiar to you and you must have faced it some time, maybe while using some versioning tool for your project like Git, TFS/TFVC, SourceSafe, etc or you might have a folder structure that ends up too long that you see above error.

For Windows 10 version 1607 and above, Microsoft introduced an option that enables you to remove the Max Path Length, users must have to enable this option to be able to remove the Max Path Length limitation as it is disabled by default.

How to enable it?

A Registry key COMPUTER\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled (Type: REG_DWORD) must exist and value set to 1.

Or

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

Alternatively, you can download the .reg file and double click to incorporate the Registry change on your computer.

Download Here

When doing Development

When you are developing an application, and while resolving assemblies or code repository throws the above exception as your folder structure is going beyond the MAX_PATH limitation.

You need to have the following XML in your application manifest file.

<application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
        <ws2:longPathAware>true</ws2:longPathAware>
    </windowsSettings>
</application>