自动保存-WPF C#

本文关键字:-WPF 保存 | 更新日期: 2023-09-27 17:58:04

有没有一种方法可以从ListView中保存详细信息,而不需要每次都使用保存对话框,并允许我在特定的时间范围内调用它。所以每次都要"保存"而不是"另存为"。

自动保存-WPF C#

您可以使用DispatchTimer和对方法的回调来执行保存。

    DispatcherTimer autosaveTimer = new DispatcherTimer(TimeSpan.FromSeconds(autosaveInterval), DispatcherPriority.Background, new EventHandler(DoAutoSave), Application.Current.Dispatcher);
    private void DoAutoSave(object sender, EventArgs e)
    {
        // Enter save logic here...
    }