SSIS 读取文件修改日期 [英] SSIS Read file modification date

查看:45
本文介绍了SSIS 读取文件修改日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 SSIS 流程,可以从各种来源导入不同格式的各种文件.这些文件中的每一个都在一个月的不同时间交付.

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:

所以我想弄清楚如何获取我读入的每个文件的修改日期.有没有办法在 SSIS 中做到这一点?

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 ?

提前致谢

推荐答案

您可以向管道添加脚本组件,该组件从输入变量读取文件名并将文件修改日期写入输出变量:

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

这篇关于SSIS 读取文件修改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆