Download pdf programmatically

后端 未结 3 2109
闹比i
闹比i 2021-02-18 23:57

How can I download a PDF and store to disk using vb.NET or C#?

The URL (of the PDF) has some rediection going on before the final PDF is reached.

I tried the bel

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-19 00:06

    You can try to use the WebClient (System.Net namespace) class to do this which will avoid any stream work on your side.

    The following C# code grabs an IRS form and saves it to C:\Temp.pdf.

    using(WebClient client = new WebClient())
    {
        client.DownloadFile("http://www.irs.gov/pub/irs-pdf/fw4.pdf", @"C:\Temp.pdf");
    }
    

提交回复
热议问题