• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

Downloading files from webpage

Hi

Does anybody know hot to download files from a web page in C#

I am trying to write an app that can download a file from a hyperlink on a web page.

Does anyone have any ideas where to start or if this is even possible.

Thanks

Mike
0
beats_m
Asked:
beats_m
  • 2
2 Solutions
 
SystemExpertCommented:
Hi,

This Link I found from search for downloading file in C3 using ASP.net

http://www.ondotnet.com/pub/a/dotnet/2002/04/01/asp.html
0
 
WinterMuteUKCommented:
I use this code to download from a given location to a given location:

      public static void DownloadFile(string url, string downloadTo)
      {
            WebClient wc = new WebClient();
            wc.DownloadFile(url, downloadTo);
            wc.Dispose();
      }

Cheers

Wint.
0
 
WinterMuteUKCommented:
In answer to the second parts of the question, yes it is possible the main trouble you will have is getting the url to download from. i.e. your app could break if you 'hardcode' the app to be at a given location. One way to attempt to solve this is to screenscrape the site, looking for the url -- but again this could break if what you are scraping for changes.

Another is just to have a user defined configuration setting which can be changed if the page doesn't exist etc.
Another another solution is to host a config file on your own site somewhere, and have your app read that, in this file you'd have the url location, and if that location changes, you update your file and clients need not know about the change at all.

The main question to ask is:
    Is the URL stable? i.e. is it dynamically created or static?

Or are you after an app which runs when a user 'clicks' on a given url in any webpage?

Wint.
0
 
SecureMetersCommented:
when i use this method it throw an exception i.e. "407 Proxy authentication reuired"

public static void DownloadFile(string url, string downloadTo)
      {
            WebClient wc = new WebClient();
            wc.DownloadFile(url, downloadTo);
            wc.Dispose();
      }

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now