Max file length

I'm getting a little confused and finding it hard to get a definitive answer on the topic.

I'm trying to store files on a synology and Windows server (some finally find their way onto a USB thumb drive or CDRW/DVDRW disc) and sometimes the file names are not accepted as they are too long.  What is the max file name I can use when generating file names to save?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Keep it under 255 characters (works for Synology/Windows)! Then again, since you use it for a lot of things, including CD's, something might go wrong there (when burning the CD in UDF, the burn software might go for safety and truncate it to 128 characters).
If you try to keep it under 128 though, it should be the most compatible I'm guessing.
Tony GiangrecoCommented:
Max file name length is 255 but it's not advisable to go that long. When you start coping files with very long file names into folders, you can run into additional problems when backing up or restoring.

Here is some suppoorting info and links that should clarify the issue:

Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:

    The following reserved characters:
        < (less than)
        > (greater than)
        : (colon)
        " (double quote)
        / (forward slash)
        \ (backslash)
        | (vertical bar or pipe)
        ? (question mark)
        * (asterisk)

Hope this helps!
dbruntonQuid, Me Anxius Sum?  Illegitimi non carborundum.Commented:
There are two components to be concerned with:

File name length: not to exceed 129 characters
Path length: not to exceed 260 characters.

So you may have a path such as C:\dir_1\sub_dir2\long_filename.ext
That total path can't exceed 260 characters and long_filename.ext can't exceed 129 characters.  Which in this case leave C:\dir_1\sub_dir2 to have a maximum length of 131 characters if long_filename.ext is 129 characters long.
In the root directory you might be able to have files with extremely long file names (the documentation isn't quite clear) but I wouldn't risk it.
anthonytrAuthor Commented:
Thanks for the comments on this.  

I have had a few files with names over 160 characters.  They seem OK in one server location and then have issues when moved.  Recently, one set of files were copied to a Synology NAS devices and have become stuck there as the file name is too long to open (I just get an error message) and too long to delete, again file name too long.

It all seems a little 'hit & miss' to me.
dbruntonQuid, Me Anxius Sum?  Illegitimi non carborundum.Commented:
It is a combination of file name length and path length and where the files are.

If they (files) are in a root directory they may be OK, lengths longer than 129 characters "may" work.
If they are in a directory then they must be 129 characters long and the maximum path (directory path length plus file name length) cannot exceed 260 characters.

If copying to another location you must check that the maximum path rule still holds.

If you can't delete using Windows Explorer then go to command line and find the short dos name for the file and delete the short dos file name using the command line.

There are a number of "Open Command prompt here" shell extensions which can be useful in Windows Explorer for this purpose.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Storage Hardware

From novice to tech pro — start learning today.