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.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Munesh SharmaPosted Sep 22, 2014, 2:36 AM
http://stackoverflow.com/questions/19312227/cannot-download-pdf-file-in-silverlight
Pramod Kumar NandagiriPosted Sep 22, 2014, 1:36 AM
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);
}