Wednesday, February 1, 2012

Get file names using Vb.net

A recent question about how to check the value of a STRING variable in SSIS 2008 ?

If you need to check for file existence on the disk...use that

1-Imports System.IO 
2- assuming your var holds a string of full pat ,ex:    C:\file.txt


Public Sub Main()
        Dim varCollection As Variables = Nothing
        Dts.VariableDispenser.LockForRead("User::FilePath")
        Dts.VariableDispenser.GetVariables(varCollection)

        If File.Exists(varCollection("User::FilePath").Value.ToString()) Then
            MessageBox.Show("File found.")
        Else
            MessageBox.Show("File not found.")
        End If

  Dts.TaskResult = ScriptResults.Success
 End Sub
You could pass 0 or 1 and use the 'Precedence constraints' to evaluate your next step.
Hope that helps someone. 

No comments:

Post a Comment