Download CSV File in Silverlight

10 Mar


you can download csv,excel or image file like jpg ,jpeg,bmp or any formate file from server on local system then

you just use this code and resolve your problem.

This line below find out the actual path of application

 string str = App.Current.Host.Source.AbsoluteUri;

// you can replace and get the path of specific folder and file with in it.

str = str.Replace(“ClientBin/SetMyLeads.Silverlight.UI.xap”, “Samplecsv/Sample.csv”);










private void sampleupload_Click(object sender, RoutedEventArgs e)



public void SaveAs()
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = “csv Files|*.csv”;

bool? dialogResult = dialog.ShowDialog();

if (dialogResult != true) return;

WebClient webClient = new WebClient();
webClient.OpenReadCompleted += (s, e) =>
using (Stream fs = (Stream)dialog.OpenFile())

catch (Exception ex)
string str = App.Current.Host.Source.AbsoluteUri;
str = str.Replace(“ClientBin/SetMyLeads.Silverlight.UI.xap”, “Samplecsv/Sample.csv”);

webClient.OpenReadAsync(new Uri(str), UriKind.Absolute);


Leave a comment

Posted by on March 10, 2012 in Silverlight


Tags: , , , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: