February 2010
Beginner
400 pages
11h 13m
English
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();
}
}
}