Public Sub Main() Dim errorInfo As String = "" Dim Contents As String = ""
Contents = GetFileContents(Dts.Variables("FileName").Value, errorInfo) If errorInfo.Length > 0 Then MsgBox(errorInfo, MsgBoxStyle.Critical, "Error") Dts.TaskResult = Dts.Results.Failure Else MsgBox(Contents, MsgBoxStyle.OKOnly, "File contents") Dts.Variables("FileContents").Value=Contents Dts.TaskResult = Dts.Results.Success End If End Sub
Public Function GetFileContents(ByVal filePath As String, Optional ByVal ErrorInfo As String = "") As String Dim strContents As String Dim objReader As StreamReader Try objReader = New StreamReader(filePath) strContents = objReader.ReadToEnd() objReader.Close() Return strContents Catch Ex As Exception ErrorInfo = Ex.Message End Try End Function