October 7, 2010 at 5:02 am
Hi All,
Is there any way to compare file creation date on ftp and local using SSIS package
please advise me on this
i will be highly grateful.
Ajit
October 7, 2010 at 9:41 am
Sure, anything is possible. I have written this type of code. I used the "Script Task" and written the code in C#.
Andrew SQLDBA
October 7, 2010 at 10:38 am
Hi AndrewSQLDBA
Thanks for replying
can you provide that script please, i would be really grateful to you
thanks in advance..
October 7, 2010 at 11:18 am
This is only part of it, you can use the C# documentation to use the different classes for files, and file control. This code compares the file time, not the date. But you can easily modify that to suit. Just use the C# Docs.
public void CopyAXAFiles()
{
FileInfo theFile = new FileInfo(Dts.Variables["FileType"].Value.ToString());
Dts.Variables["ProcessFile"].Value = false;
string AXAfileLastWriteTime = "00:00:00";
string AXAminTime = "00:00:00";
string AXAmaxTime = "00:00:00";
DateTime AXAminDateVar = DateTime.Parse(Dts.Variables["AXAMinTimeStamp"].Value.ToString());
DateTime AXAmaxDateVar = DateTime.Parse(Dts.Variables["AXAMaxTimeStamp"].Value.ToString());
AXAfileLastWriteTime = theFile.LastWriteTime.ToShortTimeString();
AXAminTime = AXAminDateVar.ToShortTimeString();
AXAmaxTime = AXAmaxDateVar.ToShortTimeString();
DateTime AXAminDate = Convert.ToDateTime(AXAminTime);
DateTime AXAmaxDate = Convert.ToDateTime(AXAmaxTime);
DateTime fileTime = Convert.ToDateTime(AXAfileLastWriteTime);
if (fileTime >= AXAminDate)
{
if (fileTime <= AXAmaxDate)
{
Dts.Variables["ProcessFile"].Value = true;
}
else
{
Dts.Variables["ProcessFile"].Value = false;
}
}
else
{
Dts.Variables["ProcessFile"].Value = false;
}
Dts.TaskResult = (int)ScriptResults.Success;
}
Andrew SQLDBA
October 8, 2010 at 1:47 am
Thanks Andrew
My programming skills are not very good but i am trying to understand your code.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply