Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
how to download a page from it url ang create a filepath for it ?
Posted
Comments
Sergey Alexandrovich Kryukov 16-Jul-12 13:42pm    
What do you mean by "create a file path". File paths are not created, they just exist when a file is created.
--SA
Nokukhanya01 16-Jul-12 13:48pm    
To Sergey Alexandrovich kryukov Meant downloading a page with it original url

1 solution

Not clear what you mean by creating of a file path (please see my comment to the question). Probably you need to understand what a download is; you download a page whenever you want; it's downloaded location have nothing do to with the location on the server.

To do it, you need to use the class System.Net.HttpWebRequest. Please see:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^].

As the instance of is created not by calling its constructor but using its parent class's factory method System.Net.WebRequest.Create, please see its description and the code sample:
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^].

This is some simple sample for file download:
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/de96a61c-e089-4595-8349-612be5d23ee6/[^].

The alternative, simplified method is the one using the class System.Net.Http.HttpClient:
http://code.msdn.microsoft.com/HttpClient-Downloading-to-4cc138fd[^].

With HttpWebRequest, you have more control. In particular, you can continue downloaded partially downloaded file. When a file was partially downloaded, but the downloading was cancelled by whatever reason, you can start with the place of the cancellation, using already downloaded part. You can find my code in my application I provided for CodeProject users a while ago:
how to download a file from internet[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900