To check where the folder has file or not ,i am going to use Script Task (.NET)
Post Creating the Variable , Copy and paste the below code into the script task.
//Declare a variable
string x;
//Assign the value to variable
x = Dts.Variables["User::FilePath"].Value.ToString();
//Check whether file exists or not
//If exists return TRUE else FALSE
Dts.Variables["User::FileExists"].Value = File.Exists(x);
The code simply takes the the X variable as the path and File.Exits(x) checks whether the file exists in the Folder path mentioned or not.
Add the below Library.
Save and Build the code.
Now we will write a expression in the Precedance constraint.
IF the File is not there, then you are supposed to log.
Now to move the file from one folder to another with timestamp , we do more changes to the above package.
we add 2 more variables,
@[User::ArchiveFolder]+"\\"+"Emp_"+ Replace (Replace (Replace (Substring ((DT_WSTR, 50) Getdate(), 1, 19), "-", ""), ":", "")," ", "_")+".txt"
Creating a Variable Filepath:
We can simply go to the Connection string properties.