Thursday, June 16, 2011

Long Name Directory Delete in Windows

Recently one of the tool have created a long directory structure in our Windows 2003 server machine. When we were trying to delete the path via explorer windows was not allowing us to do so. We have tried it through dos with rd /S option still it is not allowing us. We just went inside the leaf directory and try to delete all the files in the leaf directory, we got a message saying that "the file name or extension is too long". We have googled and find out the command to remove the directory that is too long(basically bigger than MAX_PATH=260). The solution is to give a fully qualified file name via giving \\?\fullpath. So actually if you want to remove a directory named C:\ab which contain a subfolder tree that is having a path that violate the above condition you could give the following command
rd /S \\?\C:\ab

No comments:

Post a Comment