I want to know if there is any workaround. I already have the byte array ,Now I need to save it to the location specified by the user. Anyway…
Any clues?
Thanks in advance.
http://www.silverlightshow.net/items/Using-the-SaveFileDialog-in-Silverlight-3.aspx
In the callback method, You can implement the logic of writing a file-first open the dialog box, and then get a pointer to the file stream, as shown below.
try
{
byte[] fileBytes = //your bytes here
SaveFileDialog dialog=new SaveFileDialog();
//Show the dialog
bool? dialogResult = this.dialog.ShowDialog() ;
if (dialogResult!=true) return;
//Get the file stream
using (Stream fs = ( Stream )this.dialog.OpenFile())
{
fs.Write( fileBytes, 0, fileBytes.Length );
fs.Close();
//File successfully saved
}
}
catch (Exception ex)
{
//inspect ex.Message
}
I have an SL 3 application that connects to a WCF service. This service retrieves byte arrays. I want to use FileSt ream saves the array as a pdf file. The problem is that when retrieving the byte array, an exception occurs when trying to display the SaveFileDialog, because the operation is initiated by the callback method, not from the user operation, it seems.
I want to know if there is any workaround. I already have the byte array and now I need to save it to a user-specified location. Anyway…
Any clues?
Thanks in advance.
Are you connected to the asynchronous method call method completed event? See this
http://www.silverlightshow.net/items/Using-the-SaveFileDialog-in-Silverlight-3.aspx
In the callback method, You can implement the logic of writing a file-first open the dialog box, and then get a pointer to the file stream, as shown below.
try
{
byte[] fileBytes = //your bytes here
SaveFileDialog dialog=new SaveFileDialog();
//Show the dialog
bool? dialogResult = this.dialog.ShowDialog() ;
if (dialogResult!=true) return;
//Get the file stream
using (Stream fs = ( Stream )this.dialog.OpenFile())
{
fs.Write( fileBytes, 0, fileBytes.Length );
fs.Close();
//File successfully saved
}
}
catch (Exception ex)
{
//inspect ex.Message
}