@Alex said:
Don't mix managed and unmanaged types if not necessary
And I couldn't agree more. Managed classes are .NET classes and are taken care of by garbage collection, etc. Unmanaged, or native classes are traditional C++ classes where you must manage all the memory.
In this case, you can do everything using managed code. Browse through the C# webpages on how to output to a file, and then just write the corresponding code in C++/CLI.
For example, this link here:
https://msdn.microsoft.com/en-us/library/system.io.file(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-2
Is something that I found by googling "C# File IO". You can click the tabs there to see the code snippet in C# or in C++ (which means C++ CLI here). Basically, you want this:
String^ path = "c:\\temp\\MyTest.txt";
if ( !File::Exists( path ) )
{
// Create a file to write to.
StreamWriter^ sw = File::CreateText( path );
try
{
//sw->WriteLine( "Hello" );
//sw->WriteLine( "And" );
//sw->WriteLine( "Welcome" );
sw->Write(textBox1->Text);
}
finally
{
if ( sw )
delete (IDisposable^)(sw);
}
}