gpt4 book ai didi

sql-server - SSIS读取文件修改日期

转载 作者:行者123 更新时间:2023-12-02 22:26:00 27 4
gpt4 key购买 nike

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

用户希望能够查看每个文件的修改日期,以检查他们是否定期更新。

目标是在流程结束时生成一个如下所示的表格:

Desired Table

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

提前致谢

最佳答案

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

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

关于sql-server - SSIS读取文件修改日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31556943/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com