2016-02-25 37 views
0

我有一个SSIS包,其中我使用了一个带VB的Scipt Task(见下面的代码)和一个Http连接管理器来下载一个定义的.zip文件。我希望做的和无法弄清的是循环并下载所有.zip文件到同一位置。SSIS脚本循环下载多个zip文件

任何建议将不胜感激。

这里是Visual B:

Imports System 
    Imports System.IO 
    Imports System.Text 
    Imports System.Windows.Forms 
    Imports Microsoft.SqlServer.Dts.Runtime 

    Public Sub Main() 
    ' 
    ' Get the unmanaged connection object, from the connection manager called "HTTP Connection Manager" 
    Dim nativeObject As Object = Dts.Connections("HTTP Connection Manager").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 = "C:\Users\{CurrentUser}\Documents\file.zip" 
    connection.DownloadFile(filename, 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) 

End Sub 
+0

你使用循环容器吗? – FLICKER

+0

我打算使用foreach循环容器。 –

回答

0

使用foreach循环容器内,用你的脚本需要工作的信息填入变数。然后访问脚本中的变量。