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 ...
Get Introducing .NET 4.0: with Visual Studio 2010 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.