Hi, I want to download a pdf file form silverlight application , the pdf file is in a folder in my solution , i want to give the path of the pdf to the method and it should download the pdf to the local system.
Code to download pdf file in silverlight
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Pramod Kumar NandagiriRank #6,963 · 252 reputationPosted Sep 21, 2014, 9:36 PM EDT
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "pdf Files|*.pdf";
dialog.DefaultFileName = "BeneficiaryDesignation.pdf";
if (dialog.ShowDialog() ?? false)
{
WebClient webClient = new WebClient();
webClient.OpenReadCompleted += (s, e2) =>
{
try
{
using (Stream fs = (Stream)dialog.OpenFile())
{
e2.Result.CopyTo(fs);
fs.Flush();
fs.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
};
string str = App.Current.Host.Source.AbsoluteUri;
string path = App.appConfiguration.GetPDFPath("BeneficiaryDesignation.pdf");
str = str.Replace("/ClientBin/ProjectDemo.xap", path);
webClient.OpenReadAsync(new Uri(str), UriKind.RelativeOrAbsolute);
}
Munesh SharmaRank #174 · 13.9K reputationPosted Sep 21, 2014, 10:36 PM EDT
http://stackoverflow.com/questions/19312227/cannot-download-pdf-file-in-silverlight