SSIS Read file modification date

别来无恙 提交于 2019-12-01 03:48:26

问题


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


回答1:


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;
    }


来源:https://stackoverflow.com/questions/31556943/ssis-read-file-modification-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!