Daniel Freire
Daniel Freire

Reputation: 86

Download a file from a link on a WPF Browser Application application

How do I download a file from a link on a WPF Browser Application application, I am using the method NavigationService.Navigate(http://www.google.com/docs/Arquivo.xlsx ") Works for download window opens but after that download was completed or canceled I can not but enter navigate the pages using method NavigationService.Navigate, I noticed that the Content property of NavigationService is null when I navigate to a file path, someone know what's going on?

Upvotes: 3

Views: 1428

Answers (1)

Alex Zhevzhik
Alex Zhevzhik

Reputation: 3397

I don't actually understand what are your goals.

If you need to download file it's better to use WebRequest rather than NavigationService:

        var request = WebRequest.Create("http://www.farmanager.com/files/Far20b1777.x86.20110108.msi");
        using (var stream = request.GetResponse().GetResponseStream())
        {
            using (var reader = new StreamReader(stream))
            {
                var fileContent = reader.ReadToEnd();
            }
        }

Upvotes: 1

Related Questions