Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create directories in windows with path length greater than 256

I have several level of directories in the folder path. when the path exceeds 256, then I could not create a sub-folder or file from it. Is there any chance to build paths more than this length. Can anyone help me out.

like image 384
Muthukumar Palaniappan Avatar asked Aug 09 '11 13:08

Muthukumar Palaniappan


People also ask

How do I enable paths longer than 260 characters?

Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem. Double click Enable NTFS long paths. Select Enabled, then click OK.

How do I get Windows 7 to accept file paths over 260 characters?

Hit the Windows key, type gpedit. msc, and press Enter. Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem OR continue to > NTFS. Then double-click the Enable NTFS long paths option and enable it.


2 Answers

In fact the limit on path strings is 260 characters. The underlying OS, these days, can support much longer path names, up to 32,767 characters. In order to name a path with a long name you need to use the magic \\?\ prefix, and use the Unicode version of the API.

However, many tools don't support such long names. A classic example of such a tool is Explorer which won't let you create objects with names longer than 260 characters. Because of this I strongly advise you to avoid creating such long names—doing so will save you much heartache in the long run.

like image 179
David Heffernan Avatar answered Nov 09 '22 04:11

David Heffernan


This should get you started: http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx#maxpath

Sadly it's an issue that I don't think will be going away any time soon, so you'd do well to familiarize yourself with that stuff.

As an aside, if you have access to robocopy (comes packaged with Windows Vista and 7, but is also available for XP), which supports long paths, you could create your files/subfolders in a higher-up folder and then use robocopy to move the subfolder to its desired location deeper in the folder tree.

like image 41
JAB Avatar answered Nov 09 '22 02:11

JAB