//Сохранение файла private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show(file_path); switch (file_path != "") { case (true): if (File.Exists(file_path)) { FileInfo fileInfo = new FileInfo(file_path); switch (fileInfo.Extension) { case ("txt"): StreamWriter writer = new StreamWriter(file_path); writer.Write(Program.RedactorTextBox.Text); writer.Close(); break; case ("doc"): word.Application MSOW97 = new word.Application(); word.Document document97 = MSOW97.Documents.Add(Visible: true); word.Paragraph paragraph97 = document97.Paragraphs.Add(); paragraph97.Range.Text = Program.RedactorTextBox.Text; paragraph97.Range.Font.Name = Program.Font_Name; paragraph97.Range.Font.Size = Program.Font_Size; document97.SaveAs2(file_path, word.WdSaveFormat.wdFormatDocument97); document97.Close(); MSOW97.Quit(); break; case ("docx"): word.Application MSOW = new word.Application(); word.Document document = MSOW.Documents.Add(Visible: true); word.Paragraph paragraph = document.Paragraphs.Add(); paragraph.Range.Text = Program.RedactorTextBox.Text; paragraph.Range.Font.Name = Program.Font_Name; paragraph.Range.Font.Size = Program.Font_Size; document.SaveAs2(file_path, word.WdSaveFormat.wdFormatDocumentDefault); document.Close(); MSOW.Quit(); break; } } else { Redactor redactor = new Redactor(); redactor.save_dialog_execute(); } break; case (false): break; } }
//Сохранение по другому пути private void сохранитьКакToolStripMenuItem_Click(object sender, EventArgs e) { Redactor redactor = new Redactor(); redactor.saveFile.Filter = "Файл блокнота|*.txt|Microsoft Word 97-2003|*.doc|" + "Microsoft Word|*.docx"; redactor.save_dialog_execute(); }