Knowing Your File and Folder Naming Limitations
Posted by William Diaz on November 7, 2011
Sometimes, the obvious is over looked because error messages often do not allude to the actual problem being encountered. For example, the online document management service eRoom presenting the following error when trying to open a file: “Unfortunately, eRoom was unable to open this file, because the directory could not be found.”
At first glance, this doesn’t means anything. But examining the settings of the application provides a clue:
Files opened from the eRoom are cached locally into a folder that is already nested pretty deep into the user’s profile as seen below:
In this case, a folder named 0_57dd6 is created that should contain the cached document, but the document never ends up being written into this folder. To see why, take the path and the document name and do a Word count:
Generally, a file is composed of two components: its path + file name (extension included), otherwise known as a fully-qualified file name. In Windows, this theoretical limit for a FQFN is approximately 260 characters (spaces included). The exact size of the FQFN in the example above is also approximately 260 characters. However, all file names end with what’s known as a “null terminator”, which counts as a character. So in reality, the practical limit of a FQFN is 259 characters, which explains why the file is not being written to the directory.
A note about paths: a path cannot exceed 247 characters. <C:\>3+<Path>244 = 247. Why 247? Windows needs to reserve 12 characters for the older 8.3 file naming convention (early Windows and DOS), so long filenames are backwards compatible with legacy file systems, i.e. 247 + 12 = 259.
Another important consideration is that other file systems will impose different limitations on file name sizes. CD\DVD file systems may impose different limitations on FQFNs, e.g. the UDF file system limits FQFNs to 127 characters, while newer CD\DVD file systems can handle long file naming conventions used by Windows. I have also heard of issues with Quicktime movies failing to play if the filename exceeded 63 characters.
The common issue with a file whose FQFN is longer than supported is that the files simply will not open, often without error. Other issues you run into is some right-click context menus options will be missing, like rename, cut and copy. To overcome this, simply cut the folder the file resides in and paste it higher up in the folder tree to a valid FQFN.
In the case above, changing the document cache path to something not so deeply nested in the file structure overcomes the issue. Going forward in Vista and Windows 7, Microsoft decided to move to C:\Users\Username from C:\Documents And Settings\Username to help with issues caused by nesting folders and files to deep into the folder structure, but you still need to be aware of this when dealing document management systems.
A more technically detailed article can be found here: http://msdn.microsoft.com/en-us/library/aa365247.aspx