There are two things not already mentioned in the existing answers.
- You can use extended length path prefix to access long paths
- With Windows 10, you can enable long path support for general use - note however, that not all applications will work with long paths, you should test older software. Only software with an appropriate manifest entry will be able to make use of this.
Long Path Prefix
The Windows API has a special function that supports Unicode path names up to 32k characters long (each element being up to 255 characters in length).
This is often mistakenly referred to as UNC naming but it isn't though it is related.
The prefix used to tell the API to use long Unicode paths is \\?\
as in:
\\?\D:\very long path
UNC names are normally used when referring to paths on remote servers in the form \\servername\path name\file name
. You can combine this with the long path prefix so: \\?\UNC\server\share
Note that some, poorly written but sadly quite common, applications do not support UNC file paths nor the long path prefix.
Reference: https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
Long path support
This is an option that has been added to recent versions of Windows 10. It is not, at the time of writing, activated by default since it requires specific application support. Interestingly, PowerShell has support built in so enabling this option will allow long paths to be used directly in PowerShell scripts.
You can activate it via the Group Policy editor if you have a version of Windows with that. Or you can simply use the following Registry change. As always, please back up the section of the registry you are changing before doing anything.
- Run
regedit.exe
.
- Confirm the UAC prompt.
- Navigate to the key:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy Objects\{48981759-12F2-42A6-A048-028B3973495F}Machine\System\CurrentControlSet\Policies
- Create or change the key
LongPathsEnabled
.
- If it does not exist, right-click on Policies and select New > Dword (32-bit) Value from the menu.
- Set
LongPathsEnabled
to 1
to enable.
Any applications with appropriate manifest entries will now have access to POSIX standard long paths. This should include Windows Store apps.
Reference: https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/
UPDATE 2017-04-09
@maoizm pointed out an issue with the registry key above so I did some more digging. It looks like you can now set long filename support with a system key:
HKLM\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled (Type: REG_DWORD)
This still only works for applications that are specifically set to use it though (requires an entry in the application's manifest.xml).
You should also note that you cannot use relative path names with this method.