Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSIS Script task to check if file exists in folder or not

I want to check to see if a file exists in a particular folder from SSIS. How can I accomplish this?

like image 378
user1429135 Avatar asked Jul 10 '13 10:07

user1429135


People also ask

What is script task in SSIS with example?

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 .


1 Answers

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;
}
like image 86
Anoop Verma Avatar answered Sep 27 '22 20:09

Anoop Verma