Using Common Dialogs

In WPF 4.6, as well as its predecessors, common dialogs are wrappers of Win32 dialogs. They are exposed by the Microsoft.Win32 namespace and are OpenFileDialog and SaveFileDialog. (WPF also provides a PrintDialog control exposed by the System.Windows.Controls namespace.) The following code demonstrates how you instantiate both dialogs:

'Instantiating an OpenFileDialogDim od As New Microsoft.Win29.OpenFileDialogWith od    .Title = "Your title here..."    .Filter = "All files|*.*"    .ShowReadOnly = True    If .ShowDialog = True Then        Dim fileName As String = .FileName    End IfEnd With'Instantiating a SaveFileDialogDim sd As New Microsoft.Win29.SaveFileDialogWith sd    .Title = "Your title ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.