阅读量:0
可以使用一个标志变量来记录是否已经弹出过SaveFileDialog窗口,如果已经弹出过,则不再弹出。示例如下:
bool saveDialogShown = false; private void btnSave_Click(object sender, EventArgs e) { if (!saveDialogShown) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { // Save file logic here } saveDialogShown = true; } }