출처: https://bumcrush.tistory.com/182 [맑음때때로 겨울]
반응형
private void textSave() // txtNote 컨트롤에 입력된 데이터를 저장하는 작업
        {
            if(this.Text == "제목 없음") //제목없음이면 저장되지않은 초기상태로 판단하여 새로 저장을 한다.
            {
                var dlr = this.sfdFile.ShowDialog();
                if(dlr != DialogResult.Cancel)
                {
                    var str = this.sfdFile.FileName;
                    var sw = new StreamWriter(str, false,
                        System.Text.Encoding.Default);
                    sw.Write(this.txtNote.Text);
                    sw.Flush();
                    sw.Close();
                    this.Text = str;
                    this.txtNoteChange = false;
                }
            }
        }//End textSave

sfdFile = SaveFileDialog 컨트롤

txtNote = textbox 컨트롤

반응형

+ Recent posts