【发布时间】:2020-12-09 22:19:53
【问题描述】:
我正在尝试使用脚本任务在 SSIS 中获取文件的创建日期。我创建了一个名为“User::File_Created”的变量并将该变量添加到以下脚本任务中:
public void Main()
{
string fileName = @"[FilePath]";
FileInfo fi = new FileInfo(fileName);
if (Dts.Variables.Contains("User::File_Created") == true)
{
Dts.Variables["User::File_Created"].Value = fi.CreationTime;
}
}
虽然完成后,我仍然只能看到存储在变量中的当前日期。任何帮助将不胜感激。
【问题讨论】:
-
如果在 if 块之后将
bool fireAgain = false; string message = "{0}::{1} : {2}"; foreach (var item in Dts.Variables) { Dts.Events.FireInformation(0, "SCR Echo Back", string.Format(message, item.Namespace, item.Name, item.Value), string.Empty, 0, ref fireAgain); }添加到脚本任务中,您是否看到 File_Created 中的预期值?所有这些都将得到浓缩,引用的代码也是billfellows.blogspot.com/2016/04/… -
@billinkc 是的!这很有帮助。该调试工具确实向我显示该变量正在评估为预期日期。但是,完成后,我仍然看不到写入变量值字段的正确日期。有什么想法吗?