Yes, the Script task will do the job here. Add using the System.IO statement to the beginning of the script, then something according to the lines of the following in the Main method checks the contents of the file.
public void Main() { String FilePath = Dts.Variables["User::FilePath"].Value.ToString(); String strContents; StreamReader sReader; sReader = File.OpenText(FilePath); strContents = sReader.ReadToEnd(); sReader.Close(); if (strContents.Length==0) MessageBox.Show("Empty file"); Dts.TaskResult = (int)ScriptResults.Success; }
Edit: VB.Net version 2005 ...
Public Sub Main() Dim FilePath As String = Dts.Variables("User::FilePath").Value.ToString() Dim strContents As String Dim sReader As StreamReader sReader = File.OpenText(FilePath) strContents = sReader.ReadToEnd() sReader.Close() If strContents.Length = 0 Then MessageBox.Show("Empty file") End If Dts.TaskResult = ScriptResults.Success End Sub
source share