How do I delete files or folders when Windows complains "the path is too long?"
Windows has a number of rules on the maximum lengths possible for file names, directory names and path names. The maximum length for a Windows path name is generally 260 characters, although Windows also maintains -- via a parallel set of file-access application programming interfaces (APIs) -- the ability to access paths that are 32,767 characters long. Note that the latter way of accessing file paths is always absolute; you can't have a relative path name longer than 260 characters.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Because Windows is designed to err on the side of backward compatibility, the system defaults to using the old way of using path names. Many older programs would simply break if forced to work with the new API. The new path-name system requires a different naming convention for a path to alert the system about whichever file API you want to work with. Explorer and the command line default to the old naming system, which is why attempting to work with a path name that's too long will throw an error.
If you end up with a Windows path that is apparently too deep to be deleted, you can force the use of the alternate file-designation methodology to get around the 260-character limit. Here's how to do it:
- In Explorer, Shift-right-click on the item to be deleted and select "Copy as path."
- In a command prompt, type DEL and then paste the name of the path you copied (right-click and select Paste).
- Press Home to go to the beginning of the line, and modify the drive letter for the Windows path so that it reads \\?\<driveletter>:\. For example, if the path begins with D:\, modify so it reads \\?\D:\.
- Windows should delete the file or folder successfully.
Do you have questions for our experts? Email firstname.lastname@example.org.
Dig Deeper on User passwords and network permissions
Related Q&A from Serdar Yegulalp
This week, our expert answers the question of how to get DVD data off a disc, even if the user's PC doesn't have an optical drive.continue reading
This week, our expert answers a question on how to connect a phone or tablet to a USB drive with a micro-USB connector.continue reading
Open source and free suites such as LibreOffice and OpenOffice could save organizations money, but not effort in comparison with Microsoft Office.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.