DPhoenix121
asked on
Save text box to file
I am trying to save some information entered into a text box to a file. This is what i have, but I keep getting the error that follows. I tried changing it to myStream->Write(tp) but that doesn't work either. Help Please!!
private: System::Void button3_Click(System::Obje ct * sender, System::EventArgs * e)
{
Stream *myStream;
SaveFileDialog* saveFileDialog1 = new SaveFileDialog();
saveFileDialog1->Filter = S"txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
saveFileDialog1->FilterInd ex = 2 ;
saveFileDialog1->RestoreDi rectory = true ;
if(saveFileDialog1->ShowDi alog() == DialogResult::OK)
{
if((myStream = saveFileDialog1->OpenFile( )) != NULL)
{
// Code to write the stream goes here.
String *tp = this->OutputBox->ToString( );
myStream->WriteText(tp,0,t his->Outpu tBox->ToSt ring()->Le ngth);
myStream->Close();
}
}
}
private: System::Void button3_Click(System::Obje
{
Stream *myStream;
SaveFileDialog* saveFileDialog1 = new SaveFileDialog();
saveFileDialog1->Filter = S"txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
saveFileDialog1->FilterInd
saveFileDialog1->RestoreDi
if(saveFileDialog1->ShowDi
{
if((myStream = saveFileDialog1->OpenFile(
{
// Code to write the stream goes here.
String *tp = this->OutputBox->ToString(
myStream->WriteText(tp,0,t
myStream->Close();
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think that in C# you need to declare:
Stream myStream;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
instead of as pointers, according to the help documentation in VS.
P.S.: You forgot to write what error you get :-)
Stream myStream;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
instead of as pointers, according to the help documentation in VS.
P.S.: You forgot to write what error you get :-)
ASKER
Thanks everyone. Amit_Q's answer worked perfectly. Really appreciate it.
MAHESH