Can anyone help me to download HTTP Url link using VB2010 or C# script.
Right now I am using the below script, but its showing DTS script task : Run time error
Imports SystemImports System.IO
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.SqlServer.Dts.Runtime
<Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute()> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
Public Sub Main()
' Get the unmanaged connection object, from the connection manager called "HTTP Connection Manager"
Dim nativeObject As Object = Dts.Connections("SourceUrl_WESTROX1").AcquireConnection(Nothing)
' Create a new HTTP client connection
Dim connection As New HttpClientConnection(nativeObject)
' Download the file #1
' Save the file from the connection manager to the local path specified
Dim filename As String = "\\zsa01\EEMS\Dev\COGEN\WESTROX1\WESTROX1.CSV"
connection.DownloadFile("\\zsa01\EEMS\Dev\COGEN\WESTROX1\WESTROX1.CSV", True)
' Confirm file is there
'If File.Exists(filename) Then
' MessageBox.Show(String.Format("File {0} has been downloaded.", filename))
'End If
'' Download the file #2
'' Read the text file straight into memory
'Dim buffer As Byte() = connection.DownloadData()
'Dim data As String = Encoding.ASCII.GetString(buffer)
'' Display the file contents
'MessageBox.Show(data)
Dts.TaskResult = ScriptResults.Success
End Sub
End Class
Thanks in advance.