Esempio n. 1
0
 private void ProcessSaveBeforeClose()
 {
     if (isModify)
     {
         DialogResult answer = MessageBox.Show("변경사항이 있습니다. 저장하시겠습니까?", "저장",
                                               MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (answer == DialogResult.Yes)
         {
             if (currfileName == firstFileName)
             {
                 if (DlgSaveText.ShowDialog() == DialogResult.OK)
                 {
                     StreamWriter sw = File.CreateText(DlgSaveText.FileName);
                     sw.WriteLine(TxtMain.Text);
                     sw.Close();
                 }
                 else
                 {
                     StreamWriter sw = File.CreateText(currfileName);
                     sw.WriteLine(TxtMain.Text);
                     sw.Close();
                 }
             }
         }
     }
 }
Esempio n. 2
0
        private void MnuSave_Click(object sender, EventArgs e)
        {
            if (curFileName == firstFileName)
            {
                if (DlgSaveText.ShowDialog() == DialogResult.OK)
                {
                    curFileName = DlgSaveText.FileName;
                }
            }
            StreamWriter sw = File.CreateText(curFileName);

            sw.WriteLine(TxtMain.Text);

            IsModify = false;
            sw.Close();
            this.Text = $"{curFileName}";
        }
Esempio n. 3
0
        private void MnuSaveFile_Click(object sender, EventArgs e)
        {
            if (currFileName == firstFileName)
            {
                DlgSaveText.Filter = DlgOpenText.Filter = "Text file (*.txt)|*.txt|Log file(*.log)|*.log";
                if (DlgSaveText.ShowDialog() == DialogResult.OK)
                {
                    currFileName = DlgSaveText.FileName;
                }
            }
            StreamWriter sw = File.CreateText(currFileName);

            sw.WriteLine(TxtMain);

            IsModify  = false;
            this.Text = $"{currFileName} - 내 메모장";
            sw.Close();
        }