I am new to SSIS . I am trying to use Script Task to get the last modified date and create date of a file. I have declared two variables to read the file path and file name (File_Path,Filename) in my script task as variables with scope as package and datatype as string.
I want to store the create date and modified date to two diff output variables(Create_Date,Last_Updated) with datatype as Datetime.
my code for the script is as follows
FileInfo fileInfo = new FileInfo(Path.Combine(Dts.Variables["File_Path"].Value.ToString(), Dts.Variables["Filename"].Value.ToString()));
if (fileInfo.Exists)
{
// Get file creation date
Dts.Variables["Create_Date"].Value = fileInfo.CreationTime;
// Get last modified date
Dts.Variables["Last_Updated"].Value = fileInfo.LastWriteTime;
}
else
{
Dts.Events.FireWarning(1, Dts.Variables["System::TaskName"].Value.ToString()
, string.Format("File '{0}' does not exist", fileInfo.FullName)
, "", 0);
}```