Pulling Files From a Web Site based on the URL path.

G

Guest

Hello,

I have a client that is feeding PDF files to me. They do not want me to
link to their files since that can put a strain on their bandwidth. What
they asked I do is download the file and store it on my server.

My question is, how do I download a file based on a url at runtime?

In other words, I have an xml file from my client with hundreds of PDF file
urls. I want to write a program that parses out the XML file and
automatically downloads the PDF files and places them locally on my server.

How would this be done?

I dont need to know how to parse the XML file or add the files to my server.
I just need to know the method of how to pull the file from their server
programatically.

I'm sure this is extremly easy, I just dont know where to start.

Thanks,

J
 
G

Guest

The most simplistic way is to use the WebClient DownloadData method, wich
returns a byte array. YOu can then create a filestream with the appropriate
name and extension and write this to a PDF file.
Peter
 
G

Guest

Thanks to both of your responses. That helped me a bunch. I don't know
which one I am going to use but I think I will try the .net 2.0 way first.

J
 
S

Steven Cheng[MSFT]

Hi J,

If the files you want to programmaticaly download are located through http
url, the .NET framework 1.1's network components are enough. One
improvement of .NET 2.0's webreuqest components is the FtpWebRequest which
can help handle Ftp protocol communications. And for normal http based
file download/upload, the webclient class(available in both 1.1 and 2.0) is
a simple and quick solution. Also, if you want to have more control on the
underlying http message, you can choose to use httpwebrequest class
directly. Here are some articles mentioned using those component to
download http base files:

#Uploading and Downloading Files
http://www.c-sharpcorner.com/Internet/WebRequestNResponseMDB.asp

#Download a Web Pages Contents and Save them to a File in VB.NET
http://www.freevbcode.com/ShowCode.asp?ID=2174

Hope this also helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top