编程语言
首页 > 编程语言> > c# – 如何防止SaveFileDialog提示两次替换/覆盖文件?

c# – 如何防止SaveFileDialog提示两次替换/覆盖文件?

作者:互联网

如何阻止System.Windows.Forms.SaveFileDialog提示两次替换所选文件,而只提示一次?

要么我错过了什么,我的安装有问题,或者默认行为只是愚蠢.

var saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
// User selects file and clicks "Save" within the dialog

我没有做任何特别的事情,这是一个空的Windows Forms项目,针对的是.NET Framework 4.7.2.

编辑:添加完整的Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var saveFileDialog = new SaveFileDialog();
            saveFileDialog.ShowDialog();
        }
    }
}

解决方法:

这似乎是最新的.Net版本中的一个错误.
在10.0.17763之前的Windows版本中不会发生这种情况

标签:c,net,winforms,savefiledialog,net-4-7-2
来源: https://codeday.me/bug/20190607/1193908.html