Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any length-limits of file path in NTFS?

Why can not I create a deep path whose characters in path is more than 255 in NTFS File System? It seems a limits of FAT32, but also exist in NTFS? Can anyone provide some documents?

Many Thanks!

like image 401
user25749 Avatar asked Dec 07 '09 01:12

user25749


People also ask

What is the maximum file name length for NTFS file system?

The maximum filename length on a NTFS partition is 256 characters, and 11 characters on FAT (8 character name, . , 3 character extension). NTFS filenames keep their case, whereas FAT filenames have no concept of case (however the case is ignored when performing a search etc on NTFS).

Can file paths be too long?

When you try to access file I/O on a specific path, the Windows API always checks if the path is longer than the MAX_PATH limit. Most standard applications, including Windows Explorer (File Explorer), do not work correctly with long path files exceeding 256 characters.

How long can a file path be in Windows 10?

By default, Windows uses a path length limitation (MAX_PATH) of 256 characters: Naming Files, Paths, and Namespaces.

Is there a limit to filename length?

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.


2 Answers

The 260 character limitation is not a limitation of the file system, but of the Win32 API. Win32 defines MAX_PATH as 260 which is what the API is using to check the length of the path passed into functions like FileCreate, FileOpen, etc. (which are used by .NET in the BCL).

However, you can bypass the Win32 rules and create paths up to 32K characters. Basically you need to use the "\\?\C:\MyReallyLongPath\File.txt" syntax which you may not have seen before. Last I checked, the File and FileInfo classes in .NET prevented you from using this type of path, but you can definitely do it from C/C++. Here's a link for more info.

http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx

like image 120
Matt Dotson Avatar answered Oct 15 '22 14:10

Matt Dotson


Quoted from wikipedia

File names are limited to 255 UTF-16 code words. Certain names are reserved in the volume root directory and cannot be used for files. These are: $MFT, $MFTMirr, $LogFile, $Volume, $AttrDef, . (dot), $Bitmap, $Boot, $BadClus, $Secure, $Upcase, and $Extend;[3] . (dot) and $Extend are both directories; the others are files. The NT kernel limits full paths to 32,767 UTF-16 code words.

http://en.wikipedia.org/wiki/NTFS

like image 32
YOU Avatar answered Oct 15 '22 14:10

YOU