SaveFileDialog

3/30/2010 8:29 PM
You can subscribe to this wiki article using an RSS feed reader.

First, you need to import a reference to the File Dialog Service:

    [Import(SoapBox.Core.Services.FileDialog.FileDialogService,
            typeof(IFileDialogService))]
    private Lazy<IFileDialogService> fileDialogService { get; set; }

Then you can use that service to get a file name from a Save File Dialog:

    private Dictionary<string, string> filters
        = new Dictionary<string, string>();

    filters.Add("txt", "Text Files");

    bool addExtension = true;
    bool checkFileExists = false;
    bool checkPathExists = true;

    string fileName = fileDialogService.Value.SaveFileDialog(
            "txt", @"c:\", filters,
            "My Save File Dialog Title",
            addExtension, checkFileExists, checkPathExists);
    if(fileName != null)
    {
        // do something with it
    }
Tags:
Home: SoapBox Core What's new: Recently changed articles