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