Example #1
0
        private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            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.RedactTB.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.RedactTB.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.RedactTB.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
                {
                    Readactor readactor = new Readactor();
                    readactor.save_dialog_execute();
                }
                break;

            case (false):

                break;
            }
        }
Example #2
0
        private void сохранитьКакToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Readactor readactor = new Readactor();

            readactor.saveFile.Filter =
                "Файл блокнота|*.txt|Microsoft Word 97-2003|*.doc|" +
                "Microsoft Word|*.docx";
            readactor.save_dialog_execute();
        }