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

Discussion in 'ASP .Net' started by Guest, Feb 3, 2006.

  1. Guest

    Guest 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
    Guest, Feb 3, 2006
    #1
    1. Advertising

  2. 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

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "" wrote:

    > 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
    >
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Feb 3, 2006
    #2
    1. Advertising

  3. Easy
    dotnet 2.0 system.net.WebRequestMethods.File

    Intermediate
    dotnet 1.1 system.net.webrequest.

    Download the 101 samples for vs 2003 and grab the how to send and receive
    data example
    http://www.microsoft.com/downloads/...20B-A3B1-3074505C03F3&displaylang=en#filelist

    Good Luck
    DWS
    reply to the group or thread if you need more help on this.


    "" wrote:

    > 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
    >
    >
    >
    =?Utf-8?B?RFdT?=, Feb 3, 2006
    #3
  4. Guest

    Guest 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

    <> wrote in message
    news:...
    > 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
    >
    Guest, Feb 4, 2006
    #4
  5. 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.)
    Steven Cheng[MSFT], Feb 6, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    7
    Views:
    461
    Stefan Behnel
    Aug 22, 2007
  2. Replies:
    4
    Views:
    323
    Tim Williams
    Nov 28, 2007
  3. Replies:
    7
    Views:
    167
    ThatsIT.net.au
    Mar 31, 2007
  4. Robert Hindla

    ROOT Asp.net Path problem. Hair-Pulling time.

    Robert Hindla, Jun 13, 2007, in forum: ASP General
    Replies:
    0
    Views:
    119
    Robert Hindla
    Jun 13, 2007
  5. Replies:
    5
    Views:
    139
    J. Gleixner
    Aug 17, 2006
Loading...

Share This Page