Friday, February 12, 2010

You cannot delete a file or a folder on an NTFS file system volume

You cannot delete a file or a folder on an NTFS file system volume where the files exist in paths that are deeper than MAX_PATH characters

Easiest way I find to delete folders like this is with the good old command prompt, using the remove directory command. The /S option will delete the entire tree below this folder and the /Q option will bypass any confirmations, so be sure you want to delete the directory you've specified.

Z:\>rmdir /?
Removes (deletes) a directory.

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.

/Q Quiet mode, do not ask if ok to remove a directory tree with /S

Z:\>RMDIR /S /Q Z:\DSMC

Microsoft has their own recommendations below:

Resolution 1: Use an auto-generated 8.3 name to access the file

To resolve this issue, you may want to use the auto-generated 8.3 name to access the file. This resolution may be the easiest resolution if the path is deep because the folder names are too long. If the 8.3 path is also too long or if 8.3 names have been disabled on the volume, go to Resolution 2. For additional information about disabling 8.3 file names on NTFS volumes, click the following article number to view the article in the Microsoft Knowledge Base:
121007 (http://support.microsoft.com/kb/121007/ ) How to disable the 8.3 name creation on NTFS partitions

Resolution 2: Rename or move a deep folder

Rename the folder so that the target files that are deeper than the MAX_PATH no longer exist. If you do this, start at the root folder (or any other convenient place), and then rename folders so that they have shorter names. If this step does not resolve this issue (for example, if a file is more than 128 folders deep), go to Resolution 4.

Resolution 3: Map a drive to a folder in the structure of the path

Map a drive to a folder inside the structure of the path of the target file or folder. This method shortens the virtual path.

For example, suppose you have a path that is structured as follows:
\\ServerName\SubfolderName1\SubfolderName2\SubfolderName3\SubfolderName4\...
In this path, the total character count is over 255 characters. To short the length of this path, to 73 characters, map a drive to SubfolderName4.

Resolution 4: Use a network share that is as deep as the folder

If Resolution 1, 2, and 3 are not convenient or do not resolve the issue, create a network share that is as deep in the folder tree as you can, and then rename the folders by accessing the share.

No comments: