[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]MVVM Framework
  [Expand]ViewModels
  [Expand]Commands
  [Expand]Behaviors
  [Collapse]Services
    Getting Started
    Services in ViewModelBase descendants
    Services in POCO objects
    Services in custom ViewModels
    View creation mechanisms
   [Collapse]Predefined Set
    [Expand]Dialog Services
    [Expand]Message Box Services
    [Expand]Document Services
    [Expand]ViewInjectionService
    [Expand]Report Services
     NotificationService
     TaskbarButtonService
     ApplicationJumpListService
     DXSplashScreenService
     DispatcherService
     FrameNavigationService
     LayoutSerializationService
     FolderBrowserDialogService
     OpenFileDialogService
     SaveFileDialogService
     WizardService
     NotifyIconService
    How to create a Custom Service
  [Expand]DXBinding
  [Expand]MIF
   Converters
   ViewLocator
   Messenger
   Data Annotation Attributes
   LayoutTreeHelper
   Weak Event
 [Expand]Controls and Libraries
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

SaveFileDialogService

The SaveFileDialogService is an ISaveFileDialogService implementation that allows you to save data of a ViewModel to a file by using the standard dialog box.

To use the SaveFileDialogService, attach it to a View as described in Attaching MVVM Behaviors and Services.

Next, access the attached service and use the service's ISaveFileDialogService.ShowDialog method to display a dialog box.

A description on how to obtain a service from a View Model is available here: Services in POCO objects and Services in ViewModelBase descendants.

Then, use the FileInfoWrapper object that is stored in the ISaveFileDialogService.File property to save your data. By default, the SaveFileDialogService uses values of DefaultFileName and SaveFileDialogService.DefaultExt properties to name the file that will be used as the ViewModel's data storage. However, an end-user can specify the file name manually by using the corresponding dialog box fields.

Note

The SaveFileDialogService uses its own FileInfoWrapper class implementing the IFileInfo interface to represent the selected file(s). This class provides the capabilities of the standard FileInfo to work with FileStream objects.

Expanded Example

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T300099.

Is this topic helpful?​​​​​​​