ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Catalog Namespace / SaveItemDialog Class / OverwritePrompt Property
Example

In This Topic
    OverwritePrompt Property
    In This Topic
    Gets or sets if a prompt will appear when a file with the same name already exists.
    Syntax
    public bool OverwritePrompt {get; set;}
    Public Property OverwritePrompt As Boolean
    Remarks

    If the file name and path provided in the Browse dialog conflicts with an existing file and this property is true, a prompt will appear asking if you want to overwrite the existing file. If you click No, indicating you don't want to overwrite the existing file, you have an opportunity to provide a different file name in the Browse dialog box. If you click Yes, the full path to the existing file is returned by the Browse dialog box. Code that generates the output file will have the opportunity to overwrite the existing file.

    If the file name and path provided in the Browse dialog conflicts with an existing file and this property is false, a prompt will not appear to ask if you want to overwrite the existing file. Code that generates the output file will have the opportunity to overwrite the existing file.

    Example
    Show_SaveItemDialog
    SaveItemDialog saveMapFileDialog = new SaveItemDialog()
    {
      Title = "Save Map File",
      InitialLocation = @"C:\Data\NewYork\Counties\Maps",
      DefaultExt = @"mapx",
      Filter = ItemFilters.Maps_All,
      OverwritePrompt = true
    };
    bool? result = saveMapFileDialog.ShowDialog();
    
    if (result == true)
    {
      ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Returned file name: " + saveMapFileDialog.FilePath);
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also