Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Windows, what is the maximum file name length considered acceptable for an app to output? (Updated and clarified)

Many Windows applications (e.g., almost all .NET apps) cannot open paths more than 260 characters in length. I am batch renaming a list of podcast files. I want to name each file after the title of the episode, but the titles are up to 100 characters long. This means that if a user saves the file in a deep directory with a very long path, they may hit the limit and be unable to open the file in those other applications.

Is it acceptable for my program to put out file names this long, and leave it to the user to deal with very long paths when it comes up? iTunes crops at 40 chars, but that seems very conservative.

Thanks to Ben Voigt for clarifying that this only applies to certain apps.

like image 826
Alex Avatar asked Dec 29 '11 23:12

Alex


People also ask

What is the maximum length of file name in Windows?

The Windows API imposes a maximum filename length such that a filename, including the file path to get to the file, can't exceed 255-260 characters.

What is the max length of a file name?

The maximum length of a pathname is 256 characters, which includes all parent directories and the filename. 255-character mixed-case long filename is possible only for files, or folders with no sub-folders, at the root folder of any drive.

What is the maximum file name length in Windows 10?

In Windows 10, you can enable long file name support, which allows file names up to 32,767 characters (although you lose a few characters for mandatory characters that are part of the name). To enable this, perform the following: Start the registry editor (regedit.exe)

What is the maximum support file name length in the NTFS file system?

The Windows FAT and NTFS file systems are not limited to 8.3 file names, because they have long file name support, but they still support the 8.3 version of long file names.


1 Answers

Windows does NOT have a limit of 255 characters for file paths.

CreateFileA has a limit of 260 characters. CreateFileW supports names up to about 32760 characters (64kB).

Some filesystems impose additional limits on the maximum directory nesting level, or the maximum length of each part.

You're probably thinking of certain popular Windows programs that have a 255 character limit, but accommodating those with a warning or user-configurable setting is probably more appropriate than adding your own hard limit.

like image 148
Ben Voigt Avatar answered Nov 05 '22 20:11

Ben Voigt