URLDownloadToFile Doesn't work in VB.NET?

  • Thread starter Thread starter Steeden Macdonalds via .NET 247
  • Start date Start date
S

Steeden Macdonalds via .NET 247

Hi,

Can anyone help me with this, I'm trying to use URLDownloadToFile in VB.NET but it doesn't seem to work. I've tried using DownloaFile in System.Web.Webclient but this doesn't suit my purpose.

Sample codes below:

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim lErrcode As Long
Dim sFullImageURL As String = "http://itg.unl.edu/new_itg/Resources/ExcelGraphs.pdf"
Dim sLocalFileName As String = "C:\Temp1\Test.pdf"

lErrcode = URLDownloadToFile(0, sFullImageURL, sLocalFileName, 0, 0)
If lErrcode <> 0 Then
Call Err.Raise(123, "Error while creating local copy of PDF document. Error Code = " & lErrcode)
End If
 

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

Back
Top