What is the longest file path that Windows can handle?

  • A similar question on Stack Overflow: stackoverflow.com/questions/265769/…. To be honest, I still don't understand whether the maximum length of an individual filename is 255 or 256 characters. (Even after the discussion with @phuclv below.) – john c. j. Dec 14 '20 at 12:15

Maximum Path Length (from MSDN)

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\<some 256 character path string><NUL>" where "<NUL>" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

  • 4
    You should mention that you can handle paths that exceed this limit by prefixing it with `\\?` (I think it was that character sequence). – Joey Jul 29 '09 at 8:54
  • 3
    you should also state the limit for unicode-paths mentioned in the 2nd paragraph: ~32k – akira Sep 28 '09 at 15:29
  • 260? 256 characters ignoring drive:\ and terminator. It's 2009, why do we only get a byte of characters to play around with? – Phoshi Oct 11 '09 at 16:57
  • @Phoshi The APIs to use longer paths aren't used by the OS by default, because passing in arbitarily long strings to applications that were poorly written by developers who knew the path could never be longer than 260 chars and decided to allocate a fixed length array to hold it would result in a huge number of buffer overflows leading to applications crashing and/or being exploited. Slightly better implementations by devs with the same mis-knowledge would abort because their path validation reported a too long error. – Dan Is Fiddling By Firelight May 25 '12 at 15:45

XP file path - 250 characters

Vista file path - 260 characters

The longest path on a clean install of Windows XP is 152 characters.

The longest path on a semi-clean install of Windows Vista is 195 characters

Windows XP allows file names upto 255 characters in length

Windows Vista allows even longer filenames containing upto 260 characters.


  • 5
    this is just true if you dont use the unicode-api, which extends the limit a bit (~32k, see msdn.microsoft.com/en-us/library/…) – akira Sep 28 '09 at 15:30
  • 1
    hmmm. at that rate, the limit in Win7 ought to be around 265 characters, no? – quack quixote Oct 11 '09 at 16:54
  • 1
    Why would they increase the limit by ten characters? Doesn't seem worth it, does it :\ – Phoshi Oct 11 '09 at 16:57
  • this is absolutely incorrect. The maximum filename length is still 255 characters in any Windows, since that's the NTFS limit. And MAX_PATH has always been 260 characters – phuclv Oct 10 '20 at 0:48
  • @Phoshi it's because MS didn't make that change. The limit is the same. This answer is just nonsense – phuclv Apr 9 at 2:40

Windows constant MAX_PATH is equal to 260 as other answers says, however, the real longest path is 32767.

See here.

32k is while using UNICODE, but now we must use it, so we should also use such max path length.

Also, you can take a look into my answer in SO which explains some things more detailed about maximum path length.


The "classic" limit is 260 characters: drive letter + :\ + 255 characters of filename + \ (or for rounding) + null terminator as said in the other answers

However the real internal limit is 32767 characters which can be achieved by appending \\?\ to get a fully qualified path

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters). To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path".

If due to some reasons the fully-qualified paths cannot be used then deeper directories can be accessed by mounting to a drive letter with subst/diskpart or by creating a junction/symlink to shorten the path

Since Windows 10 version 1607 the MAX_PATH limit has also been removed although not by default

Starting in Windows 10, version 1607, MAX_PATH limitations have been removed from common Win32 file and directory functions. However, you must opt-in to the new behavior.


Note that Joe's answer is completely wrong. Max (long) file name length has always been 255 characters and MAX_PATH has always been 260

  • The best answer here. The most accurate and easiest to understand. +1 – john c. j. Dec 14 '20 at 11:46
  • However, it is not clear to me what does the \ after the 255 characters of filename mean. As I know, a typical path looks like c:\foo\bar (or c:\foo\bar\a.txt), not c:\foo\bar\ (or c:\foo\bar\a.txt\). There is no trailing backslash. Could you explain what you mean by it? – john c. j. Dec 14 '20 at 11:54
  • (There were some errors in my previous comment. Now all of them are fixed.) – john c. j. Dec 14 '20 at 12:00
  • @johnc.j. as I said, it can be a path to a folder with trailing slash, or simply for making the size an even number which is better for alignment – phuclv Dec 14 '20 at 12:02
  • Prepend \\?\, don't append \\?\ – cowlinator Apr 9 at 1:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.