New version of the typical question of how to convert from std::string
to LPCTSTR
.
Reading from different SO posts I learnt that I should do th
As this question pops up when you try to find "(std::) string to LPCTSTR"
Here's a way how to convert&pass std::string
as LPCTSTR
using wstring
string path_str = "Yay!"; //your string containing path
wstring path_wstr( path_str.begin(), path_str.end() );
//then this should work:
CreateDirectory(path_wstr.c_str(),NULL);
IMPORTANT Note by Adrian McCarthy:
This is fine if the source string is ASCII or if it's ANSI and the current code page is Windows-1252 (which is very similar to Latin-1). If the source is UTF-8 or another code page, then this just hides the problem.