如何捕获循环内生成的变量的子字符串并将其传递给以下任务?

How do I capture a substring of a variable generated inside a loop and pass it to the following task?

我有以下场景:

我正在循环访问目录中的文件。

对于每个文件,我必须捕获部分文件名,并且必须将其用作 "Update Exceptions" 任务的参数。

如何保存部分文件名(循环正在循环),然后将其作为参数传递给 "Update Exceptions?"

中的存储过程

我已经有了从文件名中提取字符串的功能,我只需要知道把它放在哪里。

同样,我想从循环所在的文件名中获取字符串 X,然后将此变量传递给 "Update Exceptions" 任务中的存储过程。

有人可以帮我吗?

创建一个对象类型的变量。注意变量的(容器)范围。

将任务的输出映射到变量。

在 ForEach 循环中使用它。

这是一种选择:

  1. 创建两个 String 变量,名为 CurrentFileCurrentFileSubstring
  2. 在你的 FELC 任务中,将 User::CurrentFile 映射到 0
  3. 在将文件移动到已处理的文件夹和更新异常之间创建脚本任务
  4. 授予您的脚本任务对 CurrentFile 的读取权限和对 CurrentFileSubstring 的读写权限
  5. 将您的函数放入脚本任务代码中。从 CurrentFile 中读取值并将函数中的子字符串值写入 CurrentFileSubstring.
    Dts.Variables[User::CurrentFileSubstring].Value = MySubstringFunction(CurrentFile);
  6. 您的更新异常任务现在可以使用 CurrentFileSubstring 值。

For more information on looping over files, see this link