Esempio n. 1
0
        public void SaveFile(FormChild df)                    //保存文件
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "文本文件(*.txt)|*.txt|RTF文件|*.rtf|所有文件(*.*)|*.*";

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                RichTextBoxStreamType fileType = TrunFileType(sfd.FilterIndex);
                file.SetFileTypeIndex(sfd.FilterIndex);
                file.SetFilePath(saveFileDialog.InitialDirectory);
                df.Sourse.SaveFile(sfd.FileName, fileType);

                df.SetFilePath(sfd.FileName);
                oldFile = fileType;
            }
            string str = df.GetFilePath();

            string[] sArray = str.Split('\\');
            fileName = sArray[sArray.Length - 1];

            for (int i = 0; i < sArray.Length - 1; i++)
            {
                filePath += sArray[i];
            }
        }
Esempio n. 2
0
        private void 保存SCtrlSToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormChild df = (FormChild)this.ActiveMdiChild;

            try
            {
                if (df.GetFilePath() == "")
                {
                    SaveFile(df);
                    MessageBox.Show("保存成功", "温馨提示");
                }
                else
                {
                    RichTextBoxStreamType fileType = TrunFileType(df.GetFileTypeIndex());
                    df.Sourse.SaveFile(df.GetFilePath(), fileType);
                    MessageBox.Show("保存成功", "温馨提示");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败,请重新保存!", "温馨提示");
            }
        }
Esempio n. 3
0
        private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormChild df = (FormChild)this.ActiveMdiChild;

            try
            {
                SaveFile(df);
                filePath = df.GetFilePath();
                MessageBox.Show("保存成功", "温馨提示");
            }
            catch (Exception ex)
            {
                return;
            }
        }