1
새 파일 이름을 저장하고 싶지만 이제는 다시 쓰기 파일 만 저장할 수 있습니다. 새 파일 이름을 저장하려고 할 때마다 경고 대화 상자가있는 메시지 상자가 나타납니다.SaveFileDialog - (파일 경로)가 존재하지 않습니다. 올바른 파일 이름이 지정되었는지 확인하십시오.
내 코드입니다, 사람이없는 것을 지적하시기 바랍니다 수 있습니까? 감사합니다.(파일 경로)이 존재하지 않습니다. 올바른 파일 이름이 이 부여되었는지 확인합니다. "다음
private void button5_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Title = "Save File";
saveFileDialog1.CheckFileExists = true;
saveFileDialog1.CheckPathExists = true;
saveFileDialog1.Filter = "Text files (*.txt)|*.txt| CONF(*.conf)|*.conf|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.ShowDialog();
if (saveFileDialog1.FileName != "")
{
// Saves the Image via a FileStream created by the OpenFile method.
System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();
// Saves the Image in the appropriate ImageFormat based upon the
// File type selected in the dialog box.
// NOTE that the FilterIndex property is one-based.
switch (saveFileDialog1.FilterIndex)
{
case 1:
saveFileDialog1.FileName = saveFileDialog1.FileName + ".txt";
break;
case 2:
saveFileDialog1.FileName = saveFileDialog1.FileName + ".conf";
break;
default:
saveFileDialog1.FileName = saveFileDialog1.FileName + ".txt";
break;
}
fs.Close();
}
}
감사합니다. 지금 파일을 저장할 수 있습니다. – Firzanah