Windows – File Name Too Long (for just Windows Explorer)

windows 7

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

Best Answer

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.

Related Question