in reply to Path and File Name Maximum Lengths

There is a lot of misinformation around. See the horse's mouth for the details,

A working approximation is 255 per path element with an overall max of 32767. But you need to use the "UNC syntax" (\\?\...) to avail yourself of the extended length.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^2: Path and File Name Maximum Lengths
by ikegami (Patriarch) on Jun 14, 2010 at 21:11 UTC

    But you need to use the "UNC syntax" (\\?\...) to avail yourself of the extended length.

    In addition to using the "UNC syntax", one needs to use CreateFileW according to the documentation. It's my understanding that open uses CreateFileA, so Win32API::File or similar is required.

      Correct. It used to be that Perl supported (some) wide file apis, but they got dropped in order to support unicode on other platforms.

      If you want to create a totally impractical path with 32k chars, compile and run this. (WARNING: It is a bitch to delete!)

      #include <stdio.h> #include <windows.h> wchar_t path[ 32768 ] = L"\\\\?\\c:\\1234567890\\"; wchar_t name[] = L"1234567890\\"; int main( int argc, char **argv ) { while( CreateDirectoryW( path, NULL ) ) { wcscat( path, name ); }; printf( "Error %d\n", GetLastError() );; }

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.