What are the Limits on File Names?

by Barry Dysert
(last updated February 29, 2016)

2

Believe it or not, file name limits aren't all that easy to come by. The reason it's difficult is because you have limits imposed by NTFS itself, limits imposed by the Windows operating system, and limits imposed by the application dealing with the files (e.g., Windows Explorer).

Experimentation reveals that for a file created at "C:\", you can create a file name with at most 255 characters. If you were to try to create a file with a longer path (e.g., "C:\Documents"), the length of the file name would have to be reduced accordingly. This implies that in addition to the length of the actual file name, you also have to deal with the name of the path, which, according to Microsoft, is set at 260 characters for local files.

File names can use any character in the current code page, including Unicode characters and characters in the extended character set (128–255), except for the following:

  • < (less than)
  • > (greater than)
  • : (colon)
  • " (double quote)
  • / (forward slash)
  • \ (backslash)
  • | (vertical bar or pipe)
  • ? (question mark)
  • * (asterisk)
  • Integer value zero, sometimes referred to as the ASCII NUL character
  • Characters whose integer representations are in the range from 1 through 31

 This tip (5835) applies to Windows 7, 8, and 10.

Author Bio

Barry Dysert

Barry has been a computer professional for over 30 years, working in different positions such as technical team leader, project manager, and software developer.  He is currently a senior software engineer with an emphasis on developing custom applications under Microsoft Windows. ...

MORE FROM BARRY

Enabling Libraries in File Explorer

Windows 7 introduced us to libraries, but they're turned off in Windows 10. Here's how to get them back.

Discover More

Creating a Desktop Shortcut for a Favorite Web Page

If you visit a certain Web page frequently, you may wish to create a desktop shortcut to take you there. This tip tells ...

Discover More

Changing the Program Associated with a File Type

Windows allows a great deal of flexibility in what programs it associates with different types of files. If you want to ...

Discover More
More WindowsTips

Repairing Your System Using a System Repair Disk

If your system gets into a state where it cannot be started normally, this tip presents you with options of how you can ...

Discover More

Checking the Size of Apps

Need to know how much disk space is consumed by the small applications (apps) installed on your system? Windows makes it ...

Discover More

Specifying a Copy Schedule in Robocopy

There are a few ways to set up a copy schedule in Robocopy by using its options. This tip explains how.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one minus 1?

2017-09-11 03:58:36

Richard

You say that the path length limit limit set by Microsoft is 260 characters for local files. What about files on a network?
This feature of the operating system has been in my mind recently, using the Office application Excel. After looking on the internet I found a DOS command to list paths in a folder structure, which I could then analyse for length to discover which paths were near the limit. The longest path I found was 212 characters but occasionally my AV suite notifies a buffer overflow message.
The command is: dir /s /b | sort /r /+261 /o pathlong.txt.
This command produces a text file containing the paths looking downwards in the folder structure from the current folder. It doesn't sort the list though - I have do that myself so I'm unsure what the sort parameter is doing.
Back to my original question - what about files on a network? Should some characters from the server be added (or subtracted from the 260 limit)?


2016-02-29 13:22:16

John Hawklyn

Don't forget reserved words: CON LPT1 etc. (https://en.wikipedia.org/wiki/Filename) can't be used in filenames.

Also there can be problems with some software correctly managing long file names with punctuation.

Usually resolved by "quoting" the file names.

It might be useful to explain why some of those characters are unavailable. Like the * asterisk and question mark - they're reserved as wildcard characters. Legacy of DOS days...


Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.