|
Imports System.Net
Public Sub Main()
Dim myWebClient As WebClient
Dim remoteUri As String
Dim localFileName As String
Dim fireAgain As Boolean
Try
myWebClient = New WebClient()
' get the context from variables
remoteUri = CStr(Dts.Variables("RemoteUri").Value)
localFileName = CStr(Dts.Variables("LocalFileName").Value)
' tell the user what we're downloading where
Dts.Events.FireInformation(0, String.Empty,
String.Format("Downloading '{0}' from '{1}'", localFileName,
remoteUri), String.Empty, 0, fireAgain)
' do the actual download
myWebClient.DownloadFile(remoteUri, localFileName)
Dts.TaskResult = Dts.Results.Success
Catch ex As Exception
' post the error message we got back.
Dts.Events.FireError(0, String.Empty, ex.Message,
String.Empty, 0)
Dts.TaskResult = Dts.Results.Failure
End Try
End Sub
|