I want to check to see if a file exists in a particular folder from SSIS. How can I accomplish this?
SSIS Script Task is an effortless task where not much configuration is needed. The initialize a Script task, the user must specify the programming language to be used, the read-only and read-write variables. Figure 2 – Script task editor. Two programming languages are supported in the SSIS Script task: Visual Basic .
Variables:
folder - string - C::\Temp\
file - string - 1.txt
fileExists - boolean - False
public void Main()
{
string folder = Dts.Variables["User::folder"].Value.ToString(); //@"C:\temp\";
string file = Dts.Variables["User::file"].Value.ToString(); //"a.txt";
string fullPath = string.Format(@"{0}\{1}", folder, file);
Dts.Variables["User::fileExists"].Value = File.Exists(fullPath);
Dts.TaskResult = (int)ScriptResults.Success;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With