views:

20

answers:

2

I have a data grid of strings which are the names of files on a remote web server.

So my question is, when the user clicks on a row in the datagrid, a corresponding file should then be downloaded by the web browser. The same way you normally browse to a website and click on a file link which then opens in the browser and begins to download.

Looked for sample codes on MSDN but i couldn't find anything that does this.

Edit: Perhaps I need to clarify. I do not want to download the file into the Silverlight app. I want the user to download the file to their local machine wherever they choose.

A: 

you can try something on these lines

WebClient webClient = new WebClient(); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged); webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted); webClient.OpenReadAsync(new Uri("....", UriKind.Relative));

for more details refer this

Vinay B R
A: 

This did the trick.

Just need to make sure that popups not disabled in the browser though but that's okay for me:

Uri downloadLink = new Uri("http://www.google.com/intl/en_com/images/srpr/logo1w.png", UriKind.Absolute);
// try to download the file via browser
System.Windows.Browser.HtmlPage.Window.Navigate(downloadLink, "_blank", "height=300,width=600,top=100,left=100");
Brock Woolf