I finally got some time to dig through all my customer feedback requests and found a glaring problem! The OpenFileDialog class has basically no content on it and so I set about correcting that. It turned out there was a nice little example already living in the Dialog Boxes Overview topic but with no links to that topic from the class, it doesn't help you out much. Anyway, here is the code sample and some art showing the new updated look for the dialog boxes with .NET Framework 4 Release Candidate. Also, I want to point out that if you choose to take the time to submit feedback on the documentation (which we really, really, REALLY appreciate), not only does an actual real person read every single comment, but we also try our best to fix it. In this case, all the comments said "need sample" so if you have a sample in mind or a property or method you want to see in action, please be specific and then you will, most likely, see something show up in the content sometime in the future.

Anyway, here is the sample code and the promised image of the new dialog. This sample creates the OpenFileDialog object, open's the dialog box and shows how you can handle the result.

VB

' Configure open file dialog box
Dim dlg As New Microsoft.Win32.OpenFileDialog()
dlg.FileName = "Document" ' Default file name
dlg.DefaultExt = ".txt" ' Default file extension
dlg.Filter = "Text documents (.txt)|*.txt" ' Filter files by extension

' Show open file dialog box
Dim result? As Boolean = dlg.ShowDialog()

' Process open file dialog box results
If result = True Then
    ' Open document
    Dim filename As String = dlg.FileName
End If

C#

// Configure open file dialog box
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.FileName = "Document"; // Default file name
dlg.DefaultExt = ".txt"; // Default file extension
dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension

// Show open file dialog box
Nullable<bool> result = dlg.ShowDialog();

// Process open file dialog box results
if (result == true)
{
    // Open document
    string filename = dlg.FileName;
}

And here is the image:

OpenFileDialog_Dev10_2

Margaret