Windows Server 2022 file name length limit

The maximum length for a path [file name and its directory route] — also known as MAX_PATH — has been defined by 260 characters. But with the latest Windows 10 Insider preview, Microsoft is giving users the ability to increase the limit.

The recent most Windows 10 preview is enabling users to change the 260 characters limit. As mentioned in the description, “Enabling NTFS long paths will allow manifested win32 applications and Windows Store applications to access paths beyond the normal 260 char limit per node.”

If you wish to utilize this feature, however, you will be required to make some edits to using Group Policy. Follow the steps below:

  1. Open Group Policy Editor [Press Windows Key and type gpedit.msc and hit Enter key.
  2. Navigate to the following directory:  Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem > NTFS.
  3. Click Enable NTFS long paths option and enable it.

Just mentioning a trick I do not see mentioned here yet.

Take this file for example:

C:\Folder1\Really Long Path\Such Recursion\So Deep\Wow\Still Going\I will run out of ideas soon\I have organizational problems\Obsessive compulsive subdirectory disorder\Here is a guid for no good reason\936DA01F-9ABD-4d9d-80C7-02AF85C822A8\Almost there\Tax Returns\2013\2013_tax_return.pdf

This full file path is 290 characters long. The shell [Windows Explorer] and most command line utilities probably won't let you touch it.

Use the subst command like so:

subst X: "C:\Folder1\Really Long Path\Such Recursion\So Deep\Wow"

Now you can access [and delete, move, etc.] the file thusly:

X:\Still Going\I will run out of ideas soon\I have organizational problems\Obsessive compulsive subdirectory disorder\Here is a guid for no good reason\936DA01F-9ABD-4d9d-80C7-02AF85C822A8\Almost there\Tax Returns\2013\2013_tax_return.pdf

And now that file name is only ~235 characters or so, so you will not encounter the "Filename is too long" problems any more.

In the Windows API, there is an infamous constant known as MAX_PATH. MAX_PATH is 260 characters. The NTFS file system actually supports file paths of up to 32,767 characters. And you can still use 32,767 character long path names by accessing the Unicode [or "wide"] versions of the Windows API functions, and also by prefixing the path with \\?\.

MAX_PATH was set in stone a very long time ago in the Windows world. I think it has something to do with ANSI standards at the time... but it's one of those things that's very difficult for Microsoft to change now, as now we have thousands of programs and applications, including some written by Microsoft themselves, that use MAX_PATH and would fail in strange new ways if the constant were suddenly changed. [Buffer overflows, heap corruption, etc.]

I'm designing a database table which will hold filenames of uploaded files. What is the maximum length of a filename in NTFS as used by Windows XP or Vista?

asked Nov 5, 2008 at 16:39

GateKillerGateKiller

72.4k72 gold badges170 silver badges204 bronze badges

9

It's 257 characters. To be precise: NTFS itself does impose a maximum filename-length of several thousand characters [around 30'000 something]. However, Windows imposes a 260 maximum length for the Path+Filename. The drive+folder takes up at least 3 characters, so you end up with 257.

answered Nov 5, 2008 at 16:45

5

This is what the "Unhandled exception" says on framework 4.5 when trying to save a file with a long filename:

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Samuel Liew

74.2k106 gold badges157 silver badges239 bronze badges

answered Apr 12, 2013 at 12:29

199 on Windows XP NTFS, I just checked.

This is not theory but from just trying on my laptop. There may be mitigating effects, but it physically won't let me make it bigger.

Is there some other setting limiting this, I wonder? Try it for yourself.

answered Nov 5, 2008 at 16:48

dovedove

20.2k14 gold badges86 silver badges106 bronze badges

12

The length in NTFS is 255. The NameLength field in the NTFS $Filename attribute is a byte with no offset; this yields a range of 0-255.

The file name iself can be in different "namespaces". So far there are: POSIX, WIN32, DOS and [WIN32DOS - when a filename can be natively a DOS name]. [Since the string has a length, it could contain \0 but that would yield to problems and is not in the namespaces above.]

Thus the name of a file or directory can be up to 255 characters. When specifying the full path under Windows, you need to prefix the path with \\?\ [or use \\?\UNC\server\share for UNC paths] to mark this path as an extended-length one [~32k characters]. If your path is longer, you will have to set your working directory along the way [ugh - side effects due to the process-wide setting].

Jesper

1,55111 silver badges10 bronze badges

answered Aug 24, 2010 at 13:51

1

According to MSDN, it's 260 characters. It includes "" -the invisible terminating null character, so the actual length is 259.

But read the article, it's a bit more complicated.

answered Nov 5, 2008 at 16:42

KibbeeKibbee

64.7k27 gold badges141 silver badges180 bronze badges

1

answered Nov 5, 2008 at 16:40

warrenwarren

31.3k20 gold badges85 silver badges119 bronze badges

I'm adding this to the above approved answer.

TO BE CLEAR, the reason people believe it to be 255-260 characters is because that is all that Windows Explorer supports. It will error out doing something like a file copy on filenames longer than that. However, a program can read and write much longer filenames [which is how you get to lengths that Explorer complains about in the first place]. Microsoft's "recommended fix" in situations like this is to open the file in the original program that wrote it and rename it.

answered Oct 9, 2012 at 14:16

2

This part of the official documentation says clearly that it’s 255 Unicode characters for NTFS, exFAT and FAT32, and 127 Unicode or 254 ASCII characters for UDF.

Apart from that, the maximum path name length is always 32,760 Unicode characters, with each path component no more than 255 characters.

answered Aug 9, 2018 at 20:31

cawcaw

30.5k60 gold badges178 silver badges287 bronze badges

1

According to the new Windows SDK documentation [8.0] it seems that a new path limit is provided. There is a new set of path handling functions and an definition of PATHCCH_MAX_CCH like follows:

// max # of characters we support using the "\\?\" syntax
// [0x7FFF + 1 for NULL terminator]
#define PATHCCH_MAX_CCH             0x8000

answered Sep 11, 2013 at 17:19

1

255 chars, though the complete path should not be longer than that as well. There is a nice table over at Wikipedia about this: //en.wikipedia.org/wiki/Filename.

answered Nov 5, 2008 at 16:44

Svante SvensonSvante Svenson

12.3k4 gold badges41 silver badges45 bronze badges

In Windows 11 [In NTFS drive] is 236 with extension

For testing rename a file with below name and try to add one character more:

1234567890123456789010123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.txt

answered Oct 21 at 4:59

MehdiMehdi

5932 gold badges7 silver badges18 bronze badges

238! I checked it under Win7 32 bit with the following bat script:

set "fname="
for /l %%i in [1, 1, 27] do @call :setname
@echo %fname%
for /l %%i in [1, 1, 100] do @call :check
goto :EOF
:setname
set "fname=%fname%_123456789"
goto :EOF
:check
set "fname=%fname:~0,-1%"
@echo xx>%fname%
if not exist %fname% goto :eof
dir /b
pause
goto :EOF

answered May 28, 2015 at 14:08

SzBSzB

9578 silver badges12 bronze badges

2

Actually it is 256, see File System Functionality Comparison, Limits.

To repeat a post on //fixunix.com/microsoft-windows/30758-windows-xp-file-name-length-limit.html

"Assuming we're talking about NTFS and not FAT32, the "255 characters for path+file" is a limitation of Explorer, not the filesystem itself. NTFS supports paths up to 32,000 Unicode characters long, with each component up to 255 characters.

Explorer -and the Windows API- limits you to 260 characters for the path, which include drive letter, colon, separating slashes and a terminating null character. It's possible to read a longer path in Windows if you start it with a \\"

If you read the above posts you'll see there is a 5th thing you can be certain of: Finding at least one obstinate computer user!

user692942

16k7 gold badges75 silver badges167 bronze badges

answered Nov 20, 2009 at 17:01

2

I cannot create a file with the name+period+extnesion in WS 2012 Explorer longer than 224 characters. Don't shoot the messenger!

In the CMD of the same server I cannot create a longer than 235 character name:

The system cannot find the path specified.

The file with a 224 character name created in the Explorer cannot be opened in Notepad++ - it just comes up with a new file instead.

answered Feb 23, 2018 at 21:12

ajehajeh

2,5702 gold badges31 silver badges60 bronze badges

1

Is there a limit to filename length?

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 length of file name in Windows?

Microsoft Windows has a MAX_PATH limit of ~256 characters. If the length of the path and filename combined exceed ~256 characters you will be able to see the path/files via the Windows Explorer, but may not be able to delete/move/rename these paths/files.

Why does Windows have a 260 character limit?

The 260-character path limit is due to fixed buffers in the runtime library for DOS/Windows path processing [e.g. ANSI Unicode, working directory, and DOSNT path conversion].

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].

Chủ Đề