Skip to Content
Introducing .NET 4.0: with Visual Studio 2010
book

Introducing .NET 4.0: with Visual Studio 2010

by Alex Mackey
February 2010
Beginner content levelBeginner
400 pages
11h 13m
English
Apress
Content preview from Introducing .NET 4.0: with Visual Studio 2010

15.12. Save File Dialog Box

A major issue in previous versions of Silverlight was that there was no capability of transferring files to a user. Silverlight 3.0 has a new file save dialog box that allows users to save content to their local machine rather than to isolated storage. This example creates a text file and then gives the user the option to save it:

void cmdSave_Click(object sender, RoutedEventArgs e)
{
    SaveFileDialog SaveDialog = new SaveFileDialog();
    if (SaveDialog.ShowDialog() == true)
    {
        System.IO.Stream fs = null;

        try
        {
            fs = SaveDialog.OpenFile();
            byte[] info =
              (new System.Text.UTF8Encoding(true)).GetBytes("Test text to write to file");
            fs.Write(info, 0, info.Length);
        }
        finally
        {
            fs.Close();
        }
    }
}

15.12.1. Filtering Files in SaveDialog ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 For Dummies®

ASP.NET 3.5 For Dummies®

Ken Cox
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9781430224556Purchase book