DTS Package – Check for file before importing into database

‘ Rename File from Connection
Option Explicit

Function Main()

Dim oFSO
Dim sFileName

sFilename = DTSGlobalVariables.Parent.Connections(“Text File (Source)”).DataSource

Set oFSO = CreateObject(“Scripting.FileSystemObject”)

‘ Check for file and return appropriate result

If oFSO.FileExists(sFilename) Then

‘Main = DTSTaskExecResult_Success
Main = DTSStepScriptResult_ExecuteTask

Else

‘Main = DTSTaskExecResult_Failure
Main = DTSStepScriptResult_DontExecuteTask

End If

Set oFSO = Nothing

End Function