3

I have a PDF file hosted on a website. I would like my VB.NET program to retrieve the file/download it and store it somewhere in %appdata%. This could be in a folder of it's own like %appdata%/my_program if you want. How do I achieve this in my VB.NET program? Thanks.

Romaan
  • 2,645
  • 5
  • 32
  • 63
James S
  • 51
  • 1
  • 6

2 Answers2

4

You can use WebClient.DownloadFile(Url,LocalPath) for downloading your PDF file and saving in a local path on your PC. The class is in System.Net Assembly.

HTX9
  • 1,717
  • 3
  • 15
  • 27
  • Thank you. I have managed to download the file into the same directory as the program, although I can't find a way to save it in the %appdata% directory. Can you please help? Thanks. – James S Nov 24 '12 at 19:53
1

Use this to download file:

    Dim WC As New System.Net.WebClient
    WC.DownloadFile(URL, FileName)

or

    My.Computer.Network.DownloadFile(URL, FileName)

To save it in the %appdata% just use :

    My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData

or

    My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData
Jet
  • 528
  • 6
  • 17