DeleteFile failure on long paths.
Date: 8/3/2012
Tags: win32api
Symptom: DeleteFile fails with ERROR_PATH_NOT_FOUND (3) when passed a path with a length greater than 260 characters.

This manifested for me when I copied a Windows XP home folder to a backup drive. The "Temporary Internet File" folder contains a lot of files with very long names. When you put those in a sub-folder with a long name, the total path length of those files tips over the 260 character limit. At that point Windows Explorer just fails to do anything useful on those files. In my case I just want to delete them. So I was poking around with i.File in an attempt to work out why these files can't be deleted. Turns out DeleteFile simply fails with super long paths.

The way around this is to share the drive with the long paths on it. Then map a drive to a deep sub-folder to reduce the file's path length to under 260 characters. THEN delete it using traditional methods.
(0) Comments | Add Comment