There is a double drive specification in your path. Change it to:
LPCWSTR path = "\\\\?\\C:test\testFile.txt";
Then it should work. Once the file has been opened, you are accessing it by a handle and can read and write as usual.
But you should avoid using long file / path names if possible. They are not supported by the MFC, C-runtime functions (e.g.
), and Shell functions (those beginning with 'SH' like
When creating files, you must also check if the file system on the destination drive or share supports long file names.
Consider also that most applications don't support long names so that such files can't be opened by those.
By the comments it has been found the error occurs by using path components that exceed the component limit. The limit can be determined with the
parameter of the
See also the Naming Files, Paths, and Namespaces
] MSDN article.