Maximum path-length or filename sizes on Windows

MSDOS could understand 8.3 file names only where 8 characters were reserved for filename and 3 for the extension. But Windows NT onwards Windows applications can create or manipulate path lengths of 260 characters, where 259 are actual characters + 1 NULL character. Moreover out of 259 characters, only 256 characters can be used for each component in the path.

C:\<256 character length><NULL>

NTFS actually can actually support 32767 characters in the paths. To handle this in your application, you must use unicode versions of file APIs such as CreateFileW etc and also prepend “\\?\” to the file paths. This tells the APIs to not to enforce 260 character limit.

To handle 32k long paths from the command line prepend “\\?\” to the paths. For e.g. to copy a file from drive c: to drive d: enter the following statement on the command prompt.

copy “\\?\c:\temp\<Long Path>” “\\?\d:\temp\<Another Long Path>”

Advertisements

2 Responses to Maximum path-length or filename sizes on Windows

  1. Rhys says:

    How would I do that? I don’t understand I wish I knew cause I need to know these commands to add to the target and I get limited.

  2. Deviloper says:

    Could you tell me what exactly are you trying to do?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: