how to use SHCreateStreamOnFileEx to create a file with a long UNC path

0

When I use SHCreateStreamOnFileEx to create a stream with a long UNC path (WCHAR, like \?\UNC\localhost\long.......long.....path\abc.txt), I got error "0x80070003 The system cannot find the path specified. ".

From http://msdn.microsoft.com/en-us/library/windows/desktop/bb759866(v=vs.85).aspx,

Remarks The SHCreateStreamOnFileEx function extends the semantics of the STGM flags and produces the same effect as calling the CreateFile function.

From http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx, *lpFileName [in] 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.*

Anyone know how to let SHCreateStreamOnFileEx support long UNC path?

Thanks!

windows
api
unc
asked on Stack Overflow Nov 28, 2013 by RickeyShao

1 Answer

1

The CreateFile function requires you to convert \\server\share\path to \\?\UNC\server\share\path, that's two backslashes in the beginning. If that doesn't work, then SHCreateStreamOnFileEx doesn't support the long paths.

answered on Stack Overflow Jun 9, 2014 by Sean Hall

User contributions licensed under CC BY-SA 3.0