So, obviously I'm expecting the output to the file to be strings of "IDS_STRINGi "Spare String"", but instead all the strings are just written "True".
I have a warning as follows:
'warning C4800: 'wchar_t *' : forcing value to bool 'true' or 'false' (performance warning)'
This obviously gives me an idea that it's coming from the line - WriteSpareStrings->Write(SpareString) and that it doesn't like wchar_t* being used there, but I don't know a way of fixing it.
I've tried writing each separate part alone, which works apart from writing the integer, where it just prints out strange characters (probably to do with using Unicode?).
If anyone has any insight on how I can fix this, I'd greatly appreciate it.
I don't see the need of mixing unmanaged C++ with C++/CLI. The .Net framework has its own version of a stringstream called a StringBuilder. Use that and write the whole thing using .Net.
To be specific: Line 13 attempts to write an unmanaged C string using a managed object that expects a managed System.String object.
Also remember this: If you have to use const_cast<>, you are most likely doing things wrong. And line 7 is no exception. If you declare SpareString of type const wchar_t* you don't have the need to use const_cast<>.
EDIT: One more thing. Same problem in line 14. Instead, use WriteSpareString->Write(Environment::NewLine);, or change 13 to use WriteLine() instead of Write().
Thanks for the quick reply. I've had a quick look into StringBuilder and have just one question: can it create and write Unicode files (like SreamWriter can specify the encoding)?