Windows 10 and the support for filenames and paths longer than 260 characters
Posted: (EET/GMT+2)
For a very long time, Windows has limited file path lengths to 260 characters. This limit could break automated builds or file operations when working with deeply nested directories. Starting with Windows 10 (version 1607) and Windows Server 2016, you can enable long path support and remove this restriction.
To enable long path support, open the "Local Group Policy Editor" tool (gpedit.msc) and then navigate to:
Computer Configuration/Administrative Templates/System/Filesystem
From there, you should find the setting named:
Enable Win32 long paths
Alternatively, you can go to RegEdit and set the registry key directly:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem] "LongPathsEnabled"=dword:00000001
No matter which way you change this setting, the operating system needs a reboot.
After rebooting, applications built with the latest Windows 10 SDK and manifest flags in place can use long paths automatically. In .NET Framework 4.6.2 and later, you can also opt in by adding the following to your app.config:
<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false;
Switch.System.IO.BlockLongPaths=false" />
</runtime>
</configuration>
It's a small but welcome change, especially if you work with DevOps CI/CD build systems, dependency restores, or nested project folders that easily exceed the old 260-character limit.
Of course, after this change, the question is: what is the limit after 260 characters? It's rather spacy 32,767 characters.
Hope this helps!