What you need to add to save from textBox-> Text text to a file:

IO::Stream^ myStream; SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog; saveFileDialog1->Filter = "Sudoky файлы (*.sdk)|*.sdk|Все файлы (*.*)|*.*"; saveFileDialog1->FilterIndex = 1; saveFileDialog1->RestoreDirectory = true; if ( saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK && saveFileDialog1->FileName->Length > 0) { if ( (myStream = saveFileDialog1->OpenFile()) != nullptr ){ myStream->Close(); } } 

1 answer 1

Found a solution thanks to: How to show the dialog "To Save File"?

 private: System::Void saveAsToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog; saveFileDialog1->Filter = "Sudoky файлы (*.sdk)|*.sdk|Все файлы (*.*)|*.*"; saveFileDialog1->FilterIndex = 1; saveFileDialog1->RestoreDirectory = true; if ( saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK && saveFileDialog1->FileName->Length > 0) { IO::File::WriteAllText(saveFileDialog1->FileName,textBox00->Text); } } 
  • one
    Remove the if line from the code - it is meaningless here. Leave only File::WriteAllText . And the variable myStream can be removed. - Alexander Petrov
  • What does this if mean? - spy686
  • @ spy686: This if is in your answer, so the question of what it means is for you. - VladD
  • it was taken from another place and for what it is not known. @VladD I consider your comment as simple ... and I can only wish you good luck. If there is nothing efficient to say, it is better to be silent. - spy686
  • @ spy686: If you are writing a solution, you and only you are responsible for it. In doing so, you, of course, need to understand what it does and how. - VladD