| softwaretime (24) | |
|
Hi everyone, I've been trying to figure out how to make, for example a button in Visual Studio C++ that can take some text from a textbox and save it as a file. But I don't mean using SaveFileDialog, I want to have it where when the user presses the button it saves the file to a pre-programmed location, and the user wouldn't be able to see anything happen (apart from the file appearing in the location of course). I've tried to use #include <fstream>, but it just generates some errors (not compiling the program). Here is my attempted code: #include <fstream> button_clicked() { String^ str = textboxX->Text; ofstream file(file.txt); file<<str; } This isn't all the code of the program, but these are the bits i have added to make it save text from a textbox to a text file. Any suggestions and advice would be appreciated as it would really help me out. Thanks in advance. | |
|
|
|
| naraku9333 (1038) | |||
The internal char array in System::String is a wide char.
If you need it to be std::string see this http://msdn.microsoft.com/en-us/library/1b4az623(v=vs.80).aspx | |||
|
|
|||