When I was copying a directory structure to a new location where the target folder had a name slightly longer that the source, I encountered the following error indicating that the file name was too long.

The interesting part is that I then used Scooter Software's Beyond Compare app to compare the Source folder to the target folder to identify the files that failed to copy. I was suprised to find that BC was able to copy the files to the target folder so both folders matched 100%.

I think the file name in question was 258 characters long. Previously, based on error messages that I probably seen in Windows Explorer, I thought that Windows had a 255 character limit on file names, including path. Since I was able to copy the following 258 char file name using Beyond Compare, this appears not be be the case.

Is there a Windows file name length limit? Why is Windows Exploere's max length 255?

It looks to me like the "name too long" restriction was

C:\Expand\tfs2010\Healthcare-Finance_IT\Main\MLR Rebates Web Services\Load_MLR_REBATE_IBOR_INFO\Load_MLR_REBATE_IBOR_INFO\Service References\IborServiceReference\Load_MLR_REBATE_IBOR_INFO.IborServiceReference.locateProfileBySourceSystemIdResponse.datasource

enter image description here


The underlying filesystem of Windows, NTFS, is much more flexible than the legacy Win32 Subsystem (win32k.sys) gives it credit for. By accessing NTFS directly and bypassing the Windows Shell, a lot of interesting possibilities appear, such as having files in the same directory whose names differ only in case (like C:\Users\hi vs. C:\Users\HI). File path length limits are another one of these legacy limitations that harkens back to Windows 95 or earlier (perhaps even DOS). Beyond Compare appears to be bypassing the Windows Shell, which is a very wise thing to do indeed for a robust file copy program.

See here for Microsoft's official answer.

| improve this answer | |
  • 2
    your link is ... the end-user version and does not provide the "whole" story: msdn.microsoft.com/en-us/library/windows/desktop/… .. in short, if OP would use unc-paths explorer would be able to access / copy the files as well, because then it would switch to the unicode-version of the file api which puts a 32k limit onto the filename. – akira Jan 28 '14 at 22:12
  • @akira: Windows Explorer (at least before Win10) doesn't support the UNC path syntax, so it can't be used as a workaround unfortunately. – Malvineous Jan 27 '17 at 7:14
  • @Malvineous it does. \\?\C:\Users for example works flawlessly, even in a Win7-WindowsExplorer. – akira Jan 29 '17 at 11:12
  • @akira: It "works" but only because Explorer converts it back to the old-style notation. Try creating a folder path longer than 260 characters and you'll see that even putting \\?\ on the front won't let you access it in Explorer. – Malvineous Jan 29 '17 at 12:42

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