Transformation of String into string
-
Got it.
textBox
its contents should be called a new text file(txt/csv/json). Problem is,textBox
may be relevantString^
and the record in the name of the file is possible with the typestring
orchar
(if I understand correctly). Mistake:E0415 doesn't have a suitable designer to transform from "System:: "String ^" into "std::basic_ofstream comchar, std::char_traits portal."
String^ n= textBox1->Text+".csv"; ofstream fname=(n);
How to transform
String^
Totalstring
or make it work, it without change, it's different.
-
If you already use cli (.NET), it's best to use local classes. Reference https://docs.microsoft.com/en-us/cpp/dotnet/file-handling-and-i-o-cpp-cli?view=msvc-160 where there are just a bunch of examples.
Because you have a stream, you probably want to write a file.
// text_write.cpp // compile with: /clr using namespace System; using namespace System::IO;
int main()
{
String^ fileName = "textfile.txt";StreamWriter^ sw = gcnew StreamWriter(fileName);
sw->WriteLine("A text file is born!");
sw->Write("You can use WriteLine");
sw->WriteLine("...or just Write");
sw->WriteLine("and do {0} output too.", "formatted");
sw->WriteLine("You can also send non-text objects:");
sw->WriteLine(DateTime::Now);
sw->Close();
Console::WriteLine("a new file ('{0}') has been written", fileName);return 0;
}