Creating a file exceeding filepath limit

listed in answer

Creating a file exceeding filepath limit
0 votes, 0.00 avg. rating (0% score)

ANSWER:

To use longer paths you need to use the “wide” version of CreateFile(), CreateFileW().

See this MSDN article on the topic:

HANDLE WINAPI CreateFile(
  __in      LPCTSTR lpFileName,
  __in      DWORD dwDesiredAccess,
  __in      DWORD dwShareMode,
  __in_opt  LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  __in      DWORD dwCreationDisposition,
  __in      DWORD dwFlagsAndAttributes,
  __in_opt  HANDLE hTemplateFile
);

lpFileName [in]

    The name of the file or device to be created or opened.

    In the ANSI version of this function, the name is limited to MAX_PATH characters.
To extend this limit to 32,767 wide characters, call the Unicode version of the
function and prepend "\?" to the path. For more information, see Naming Files,
Paths, and Namespaces.

by Alex from http://stackoverflow.com/questions/10695018