Mike Taulty's Blog
Bits and Bytes from Microsoft UK
A quick look at Silverlight 3: Save File Dialog

Blogs

Mike Taulty's Blog

Elsewhere

Silverlight 3 gets a Save File Dialog. Anyone who’s used Silverlight 2 and its Open File Dialog will feel instantly at home as in;

SaveFileDialog sfd = new SaveFileDialog()
      {
        DefaultExt = "txt",
        Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*",
        FilterIndex = 1
      };
      if (sfd.ShowDialog() == true)
      {
        // User selected item. Only property we can get to is.
        using (Stream stream = sfd.OpenFile())
        {
          stream.Close();
        }
      }

As with the Open File Dialog, the dialog has to be raised in response to a direct user interaction like clicking on a button – it can’t be raised by a (potentially malicious) piece of code.

Similarly, the only thing you can do with the dialog is to call the OpenFile() method and that gives you no details about the user’s machine or their file system but simply a Stream that you can write into and close off.

So…pretty simple stuff to use but great in terms of the number of different Silverlight Applications that this will enable :-)

This is one of a series of posts taking a quick look at Silverlight 3 – expect them to be a little “rough and ready” and that they’ll get expanded on as I’ve had more time to work with Silverlight 3.


Posted Wed, Mar 18 2009 12:07 PM by mtaulty
Filed under: ,

Comments

Mike Taulty's Blog wrote Silverlight 3: More Posts?
on Wed, Mar 18 2009 1:43 PM

Just a quick note – I didn’t want anyone to think that I’d given up on Silverlight 3 or that these posts;

A quick look at Silverlight 3 - by Mike Taulty | DavideZordan.net wrote A quick look at Silverlight 3 - by Mike Taulty | DavideZordan.net
on Thu, Mar 19 2009 5:13 AM
A quick look at Silverlight 3 – By Mike Taulty « vincenthome’s Tech Clips wrote A quick look at Silverlight 3 – By Mike Taulty « vincenthome’s Tech Clips
on Thu, Mar 19 2009 9:34 PM