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

Mac*_*inB 5 .net c# savefiledialog winforms .net-4.7.2

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

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

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

我没有做任何特别的事情,这是一个空的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();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

小智 7

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

  • KB4481031(https://support.microsoft.com/en-us/help/4481031/january-22-2019-kb4481031)修复了此.NET错误.目前,您必须转到Windows Update并单击"检查更新"才能下载和安装. (2认同)