현재 열려있는 파일을 저장하지 않고 대화 상자를 팝업하지 않고 저장하는 데 문제가 있습니다.프롬프트없이 현재 열린 파일 저장
좀 더 명확히하기 위해 .txt 파일을 열고 작업 한 다음 '저장'을 클릭하고 '다른 이름으로 저장'대화 상자를 팝업하지 않고 파일을 저장하려고합니다.
여기 내 저장 코드 :
private void SaveFile()
{
SaveFileDialog fileChooser = new SaveFileDialog();
fileChooser.Title = "Choose Save Location";
fileChooser.Filter = "Text Files (*.txt)|*.txt";
fileChooser.OverwritePrompt = false; //Removes warning
DialogResult result = fileChooser.ShowDialog();
if (result == DialogResult.Cancel)
{
return;
}
try
{
string fileName = fileChooser.FileName;
output = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
fileWriter = new StreamWriter(output);
foreach (Employee emp in employee)
{
fileWriter.WriteLine(emp.Firstname + "," + emp.Lastname + "," + emp.Position + "," + emp.Bmonth + "," + emp.Bday + "," + emp.BYear + "," + emp.Salary + "," + emp.Hiremonth + "," + emp.Hireday + "," + emp.Hireyear);
}
fileWriter.Close();
output.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
fileWriter.Close();
output.Close();
}
}
모든 위대한까지 .txt 파일에 저장하고이를 다시로드로 작동, 그것은 나를 irks 그 팝업이 단지.
, 당신은 어떻게 건너에 대해 fileChooser 대화 상자를 모두 열고 그냥 저장 하시겠습니까? 문제가 보이지 않습니다. –
코드에 파일 저장 대화 상자가 표시됩니다. 네가 원하지 않으면 ...하지 마라. –
파일을 열고 변경 한 경우 도구 모음에서 '저장'을 클릭하고 저장하려면 이름을 묻는 대신 파일을 저장하면됩니다. –