Script Task for File Exist

  • Hello,

    I am trying to identify if the folder has all total 20 files before running load task.

    My files are xx_file1_xxx.txt, xx_file2_xxx.txt .................. xx_file20_xxx.txt

    I placed a script task in foreach loop by passing file and folder names as variables.

    My script task looks like below..

    Public Sub Main()

    Dim folder as string, file as string

    folder = Dts.Variables ("User::folder").value

    file= Dts.Variables ("User::file").value

    if ( file.contains ("_file1_") or file.contains ("_file2_") or ......... file.contains ("_file20_")) Then

    dts.TaskResult = ScriptResults.Success

    Else

    Dts.TaskResult = ScriptResults.Failure

    End If

    End Sub

    End Class

    Problem: Now this code runs without any flaw but the issue is if I don't have 1 or more files out of 20 its still succeeding.

    I don't know where this condition needs to be put because my files always will be 20 in number.

  • you may want to check for the existence of all the file in one script and return true if they all exist. true will be a precedent constraint on running the for-each loop (constraint and success). The for-each loop can process your files but it won't run if true isn't returned from the script.

    Karen

Viewing 2 posts - 1 through 1 (of 1 total)

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