I’m trying to parse a SHGetSpecialFolderPath into a string, a System::String^ to be precise.
I’m now using this code:
TCHAR appDataPath;
SHGetSpecialFolderPath(0, appDataPath, CSIDL_APPDATA, false);
I’ve tried things like this, but it doesn’t work either:
LPWSTR appDataPath;
SHGetSpecialFolderPath(0, appDataPath, CSIDL_APPDATA, false);
I just want to get a System::String^ like this:
System::String ^ loc_inst = appDataPath + "\\inst\\info.xml";
I don’t think C++/CLI can automatically concatenate char arrays and assign them to a string handle. I think you need to instantiate a new
System::Stringobject like this:Or you could use a
StringBuilder, but if you want to make a newStringobject I think you’ve got to usegcnewand a constructor.Keep in mind that
appDataPathis not aStringbut a char array that you have previously allocated. However,System::Stringallows you to pass in char arrays in one of its constructors.