• On the Control Flow canvas add a Script Task and connect that to the Data Flow task.

    In the following example the Script Task loops until the file becomes available or a timeout period has expired.

    ' VB.Net

    ' Returns success if file can be opened before a timeout period has expired

    ' Note: Add Imports System.IO at beginning

    '

    ' Replace hardcoded file name with package variable.

    Dim strFilename As String = "c:\temp\input.csv"

    Dim fsMyFile As System.IO.FileStream

    Dim bFinished As Boolean = False

    Dim iCount As Integer = 1

    dim iTimeout as Integer = 60

    Do

    Try

    fsMyFile = System.IO.File.Open(strFilename,FileMode.Open,FileAccess.ReadWrite,FileShare.None)

    bFinished = True

    fsMyFile.Close()

    Catch ioex As System.IO.IOException

    iCount += 1

    System.Threading.Thread.Sleep(1000)

    End Try

    Loop Until bFinished Or iCount > iTimeOut

    If bFinished Then

    Dts.TaskResult = Dts.Results.Success

    Else

    Dts.TaskResult = Dts.Results.Failure

    End If