@ToniAz You have to use either mkdir or (on Windows) CreateDirectory, as ofstream does not know how to create a directory (you did say tht the directory did not exist?).
Note that neither mkdir() nor CreateDirectory() can create more that a single level at a time.
And "folder\\file" and ".\\folder\\file" identify the same file path. As does "./folder/file". Windows happily accepts Linux style paths as inputs, but if you retrieve a path from Windows, it will be in Windows format.
Yeah that whole mixing up between forward slash and backlash always gets me!
@Stewbond
Since you mentioned the the wide string support, why did you interchangingly used wstring and WCHAR*. Why not use wstring ony?
Also, is wstring supported by windows.h? Do you recommend using wstring and not regular string in web-based programming?
wtring is partially included in #include <iostream> and supported in full with #include <string> .
Why do I use wstring over string and WCHAR* over CHAR*? Because the windows function CreateDirectory() only accepts wide characters. These are 16-bit characters instead of 8-bit characters.