Feb 14, 2013

Maximum length for naming a file in windows


In the Windows explorer the maximum length for naming a file is 260 characters including the drive letter and folders name.
Because windows has a predefined variable called MAX_PATH and its value is set to 260.


So when you try to create or copy a file it will return below error

cp: cannot create regular file    File name too long

sample filename :
C:\hudson\workspace\dev-project-eventsourcelibrary\project\initial\eventsourcelibrary\tmp\normaliser\etc\devices\nsm\reports\Network\Configuration and Policy Management\viewScreen-Security Management\NetScreen-Security Manager - Authentication and Login Events.xml 

So to avoid either you can reduce the characters by trimming the directories name length or use the "\\?\" prefix so that it will allow upto 32,767 characters.

To know more about this, refer microsoft's naming guide.
url-
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#maxpath
----------------

No comments:

Post a Comment