If you are facing error Destination Path Too Long when trying to copy or move a file to a folder, try the quick trick below. The reason you receive the error is that File Explorer failed to copy/delete/rename any path-name longer than 256 characters. The instructions below apply to Windows XP, Windows 7, Windows 8, Windows 10, Windows Server 2003, Windows Server 2008, and Windows Server 2012R2/2016/2019.
This is not the limitation of NTFS file system, but the Win32 API library. In Win32 API the MAX_PATH value is 260. Most standard applications, including Windows Explorer (File Explorer), do not work correctly with long path files exceeding 256 characters. Under the file name, Windows understands the entire path, starting with the root of the drive, ending with the last subfolder, and the file name itself.
When using Unicode API functions, it’s possible to use a path of up to 32767 characters. Thanks to this, many third-party programs (the popular file managers, for example FAR and Total Commander) process files/folders which path length exceeds 256 characters without any problems.
Note. Some programs use the UNC file path format (prefixed with ?) to bypass the limitations of the Win32 API. For example, the absolute file path might look like this: \\?C:\folder1\subfolder1\toolongfilename.
Due to max path length limitations, the administrator may encounter the following problems:
- Users can create files and folders in a shared network folder that the administrator (or management scripts) cannot access locally;
- Errors when synchronizing roaming profiles;
- Errors data recovery from shadow copies;
- Incorrect calculation of the directories size;
- Lost of files during migration and data transfer between servers, etc.
Destination Path Too Long Fix
Full Error: “The file name(s) would be too long for the destination folder. You can shorten the file name and try again, or try a location that has a shorter path.”
Solution 1. Rename Parent Folder to Decrease the Full Path
The simplest way is to shorten the name of the parent folders, decreasing the total path length (but not always applicable) by simply renaming it.
Solution 2. Create a Symbolic Link
Another option is to create a symbolic link to a part of the path, thus shortening the total path length. To create a link, you can use the following command:
mklink /d c:\homelink “C:\verylongpathhere……”
Next, perform file operations with the directory to which the symbolic link is assigned (c:\homelink in our case).
Solution 3. Use Subst Utility
Another option is to associate the problem folder to a virtual disk (in our example, Z:), using the built-in utility Subst. Thus, you can also shorten the path length:
Subst Z: “C:\verylongpathhere……”
Now you can work with the data on the Z: drive, the path to the files in which will not exceed the Win32 API path limit. After the job is finished, you can delete the virtual disk using the Subst with the /d option:
Subst Z: /d
Solution 4. Hidden Share Path
The quickest fix for this (especially if you need to simply migrate (move) a lot of folders from one place to another) is to map a drive to the drilled down the folder.
What you should do is browse to the hidden share path and copy it to your clipboard.
Then browse to “Computer” or “My Computer”, and click on Map Network Drive. Depending on your OS, it might appear under the tools menu.
Then simply paste your long folder path and hit Finish.
Now you will be able to copy the files/folders into this location without receiving the error.
Solution 5. How to Enable Long Path Support in Windows 10 (1607) and Higher
Since Windows 10 Anniversary Update (1607), it became possible to disable the MAX_PATH limit on the Windows operation system level without using prefix \\?. By default, this feature is disabled.
To enable the built-in support for long paths in Windows 10/Windows Server 2016, use the Regedit.exe editor to set the LongPathsEnabled parameter of REG_DWORD in the registry key HKLM\SYSTEM\CurrentControlSet\ControlFileSystem with a value 1.
You can change this registry parameter with the following PowerShell command:
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\ControlFileSystem -Name LongPathsEnabled -Value 1
Or you can enable long path support via Group Policy Editor (Win + R gpedit.msc) Computer Configuration > Administrative Templates > System > Filesystem. Enable the policy Enable NTFS long paths.
In both cases, the computer needs to be rebooted to make changes to take effect. After a reboot, users and programs will be able to work without restrictions with files, which length of the path exceeds 256 characters. Now the files will only be affected by the NTFS file path limit of 32767 characters.
However, in some applications, the MAX_PATH check is embedded in the code. About the max file path restrictions for .Net developers, see the Solution 7 below.
Solution 6. Using Robocopy Utility to Copy and Move Files
You can use the built-in console Windows tool — robocopy to copy or move data. The utility allows you to correctly copy and synchronize files/directories with long paths.
For example, if you cannot delete the directory due to the path length limit, you can first move data from the directory using robocopy:
ROBOCOPY c:\folder1\folder2\folder3\longpath\ c:\tmp\ /MOVE /E
After that, you can delete the source directory:
Delete c:\folder1\folder2\folder3\longpath\ /q /f
Solution 7. Long File Path for .Net Developers
The Base Class Library (BCL) of the development environment for the .Net Framework has a built-in preliminary check for the admissibility of long directory and file names. Therefore .Net Framework developers may encounter a System.IO.PathTooLongException error in their programs.
Check for path length removed from BCL code in .Net Framework 4.6.2. Therefore, after updating the version of .Net Framework, developers can use long paths in the UNC path format (\\?C:\Very_long_path). When the LongPathsEnabled parameter is enabled in Windows 10/Windows Server 2016, it is possible to work correctly with files that have paths of almost any length.
To do this, use Net Framework 4.6.2 (and newer) when building applications, or for older app versions (.Net 4.0), use the following application configuration file:
<?xml version=”1.0″ encoding=”utf-8″?>
<supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.0″/>
<AppContextSwitchOverrides value=”Switch.System.IO.UseLegacyPathHandling=false;Switch.System.IO.BlockLongPaths=false” />
Solution 8. Long File Path in PowerShell .Net Developers
PowerShell is based on .Net, and in order for the Get-Item, Get-ChildItem, Remove-Item, and other cmdlets to work correctly with long file paths, you need to upgrade the .NET Framework to 4.5 or newer, and install Windows Management Framework 5.1.
Tip. The current version of PowerShell can be found in the variable $PSVersionTable.
After that, when using file cmdlets instead of Path, you need to use the LiteralPath parameter. For example:
Get-ChildItem -literalpath \\?C:\PS
There also is a great tool called “Long Path Tool” that works great to fix this, LongPath tool. However it isn’t free, the methods above are.
Thank you, Colin Albright, for the comment below. Yes, you can also use 7-zip or any zip utility to fix Destination Path Too Long problem. Sometimes on single files, this could be a better and faster solution. Just zip the folder up, and your good to go.