How to create directories in windows with a path length of more than 256

I have several directory levels in the folder path. when the path exceeds 256, I could not create a subfolder or file from it. Is there a chance to build paths longer than this length. Can anyone help me out.

+6
source share
3 answers

In fact, the path line limit is 260 characters. Currently, the base OS can support much longer path names, up to 32,767 characters . To name a path with a long name, you need to use the magic \\?\ Prefix and use the Unicode API version.

However, many tools do not support such long names. A classic example of such a tool is Explorer, which will not allow you to create objects with names longer than 260 characters. Because of this, I highly recommend that you avoid creating such long names, so this will save you a lot of heartache in the long run.

+6
source

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

Unfortunately, a problem that I don’t think about will leave soon, so it would be nice for you to familiarize yourself with this material.

Aside, if you have access to robocopy (comes bundled with Windows Vista and 7, but also available for XP) that supports long paths, you can create your files / subfolders in a folder with a higher name, and then use robocopy to move the subfolder to the desired location deeper in the folder tree.

+1
source

According to the documentation here http://msdn.microsoft.com/en-us/library/Aa365247 the maximum length is actually about 32,000, but most window APIs still limit you to MAX_PATH which is 260. There are some Unicode APIs that let you go beyond 260.

See here http://msdn.microsoft.com/en-us/library/aa363856 .

In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode function version and add \\?\ To the path. For more information, see the "File Naming" section.

+1
source

Source: https://habr.com/ru/post/894632/


All Articles