2012-01-11 76 views
0

在我的WPF應用程序中,如果我在保存文件時嘗試覆蓋現有文件,我想要通知覆蓋提示。SaveFileDialog OverwritePrompt not working

這是保存文件的代碼。 在savefiledialog選項中,我將覆蓋提示設置爲true,但這不起作用。

var dialogOptions = new SaveFileDialogOptions { Filter = Resources.SaveFileDialogFilter, OverwritePrompt = true}; 

var result = dialogService.SaveFile(dialogOptions, null); 

if (result == true) 
{ 
// Save the file 
} 

DialogServices.cs

public bool? SaveFile(SaveFileDialogOptions options, Window owner) 
{ 

return ShowDialog<SaveFileDialogOptions, SaveFileDialog>(options, owner); 

} 

static bool? ShowDialog<TDialogOptions, TDialog>(TDialogOptions options, Window owner) 
      where TDialogOptions : FileDialogOptions, new() 
      where TDialog : FileDialog, new() 
{ 

var dialog = new TDialog(); 
      PropertyCopy<TDialog>.CopyFrom(options, dialog); 
      var result = owner == null ? dialog.ShowDialog() : dialog.ShowDialog(owner); 
      PropertyCopy<TDialogOptions>.CopyFrom(dialog, options); 
      return result; 

} 

請回答,如果有人知道,爲什麼這是行不通的。

預先感謝

回答

2

SaveFileDialog.OverwritePrompt = FALSE;