We have an SSIS process that imports various files in different formats from various sources.
Each of these files is delivered at different times throughout the month.
The users would like to be able to see the modification date for each file, to check they are getting regular updates.
The aim would be to produce a table at the end of the process like this:
So I am trying to work out how to get the modification date of each of the files I have read in. Is there a way to do this in SSIS ?
Thanks in advance
You can add a script component to the pipeline which reads the filename from an input variable and writes the file modified date to an output variable:
/// <summary>
/// This method is called when this script task executes in the control flow.
/// Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
/// To open Help, press F1.
/// </summary>
public void Main()
{
System.IO.FileInfo theFile =
new System.IO.FileInfo(Dts.Variables["User::FilePath"].Value.ToString());
if (theFile.Exists)
{
Dts.Variables["User::LastFileDate"].Value = theFile.LastWriteTime;
}
Dts.TaskResult = (int)ScriptResults.Success;
}