script task: download files in folder over https which do not exist in local drive!

  • I found the following script to download file from http; but i also need to compare all the files on https with the files on my local archive folder and then only download those files which are not in my local archive folder. how do i add that piece in the script task?

    Thanks!

    ------------------------------------------------------------------------------------------------------------------------------------------

    Imports System

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Runtime

    Imports System.Net

    Public Class ScriptMain

    ' The execution engine calls this method when the task executes.

    ' To access the object model, use the Dts object. Connections, variables, events,

    ' and logging features are available as static members of the Dts class.

    ' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.

    '

    ' To open Code and Text Editor Help, press F1.

    ' To open Object Browser, press Ctrl+Alt+J.

    Public Sub Main()

    Dim WebConnection As New WebClient()

    'Dim proxyConnection As New WebProxy("http://proxy.server.com")

    Dim creds As New NetworkCredential("userid", "password")

    Try

    With WebConnection

    '.Proxy = proxyConnection

    .BaseAddress = "http://www5.site.com/folder/"

    .Credentials = creds

    End With

    Catch ex As Exception

    Dts.Events.FireError(0, "Problem connecting to website: ", ex.Message, "", 0)

    End Try

    Try

    With WebConnection

    .DownloadFile("http://www5.site.com/folder/", "file.zip")

    End With

    Catch ex As Exception

    Dts.Events.FireError(0, "Problem downloading file: ", ex.Message, "", 0)

    End Try

    Dts.TaskResult = Dts.Results.Success

    End Sub

    End Class

  • I think Regex may also accomplish this; has anyone used Regex in VB.Net? thx

  • how about OpenRead method? Does it work?

  • When you say "compare files", do you mean compare them by file name or by content?

  • by filename, if filename can be found in local drive, then do not download(loaded already before), if filename not found in local drive then download that file.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply