Window 256 characters path name limitation

ntfswindows 7

after a long research, I finally found out that pathnames cannot be longer than 256 characters even in the latest Microsoft Windows 7. I really don't get it why there is such a stupid limitation, since NTFS can handle up to ~32,000 characters path length without any problem since more than a dozen years! Isn't there any possibility to change that? Or are there any practical solutions to avoid that?

260 characters are just very few for even simple use cases like some nested photo directories with long file names.

Best Answer

According to Microsoft:

  • The traditional Windows API limits path names to 260 characters, even for applications developed for the latest version.

  • Applications using the Unicode-aware API can use a form of path that allows up to 32767 characters. The file name has to be prefixed with \\?\, and must be an absolute path, e.g., \\?\c:\dir\file or \\?\UNC\server\share\file. There are further limitations, see the reference for details.

If you've managed to create and use a deep file hierarchy and need to work with an application that bombs out because of file name length, there are a few things you can try:

  • Use the mklink command to create symbolic links, and pass a path that uses them to your application.

  • Use the subst command to assign a drive letter to a directory.

  • Start your application from a deep directory and pass it short relative paths.

  • Replace some long names by their 8.3 aliases (micros~1), assuming those still exist in Windows 7. If you have micros~1 alongside micros~2, I don't know how to tell which is which; perhaps run DOS command.com (again, assuming Windows 7 can still do it).