Не удается получить диалог сохранения файла для работы с моей программой. Я использую visual studio 2012. Откроется диалоговое окно сохранения, и я могу поместить имя файла, но оно фактически не будет сохранено.Диалоговое окно сохранения файла
try
{
//declare a stream writer variables
StreamWriter outputfile;
//create a file and get a streamwriter object
outputfile = File.CreateText("organisms.txt");
//write the data to the file
for (int b = 0; b < listBox1.Items.Count; b++)
{
outputfile.WriteLine(listBox1.Items[b].ToString());
}
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
MessageBox.Show("You clicked the save button");
}
else
{
MessageBox.Show("You hit the cancel button");
}
//close the file
outputfile.Close();
}
@VivekSinghNegi, что не имеет смысла – Itsik
Используйте this.Close() вместо outputfile.Close(); – CodeConstruct