次の解決策は、問題の解決に役立つ場合があります。
で For each ループ コンテナーを使用し"Item" enumerator
ます。10 個のファイルがあり、レイズが必要な何かが不足している場合は、これを使用する必要があります。ファイル列挙子はファイルを反復処理するだけで、エラーは発生しません。
以下は手順です。
変数を使用して次の SSIS パッケージを作成します。
- ファイルフルパス
- 検証済み
各ループ列挙子は、次のスクリーンショットのように構成する必要があります。
コレクションの構成:

変数セクションの設定

コンテナー内にはスクリプト タスクがあります。FileFullPath
次の画面のように、読み取り専用変数とIsValidate
読み取りおよび書き込みとして言及する必要があります。

[スクリプトの編集] をクリックし、次のコードを挿入します。
public void Main()
{
Dts.Variables["IsValidated"].Value = true;
string fileFullPath = Dts.Variables["FileFullPath"].Value.ToString();
if (!File.Exists(fileFullPath))
{
var msg = String.Format("File is not available in location : {0}", fileFullPath);
Dts.Events.FireError(0, "Dat file loading", msg, string.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
//Read last line
String lstLine = File.ReadLines(fileFullPath).Last();
int totalCount = 0;
bool talierExists = int.TryParse(lstLine, out totalCount);
if (!talierExists)
{
var msg = String.Format("No tailer row found and last line is : {0}", lstLine);
Dts.Events.FireError(0, "Dat file loading", msg, string.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
//Total count
int fullCount = File.ReadLines(fileFullPath).Count();
if (fullCount != totalCount)
{
var msg = String.Format("No of count is not matching, tailer count = {0} and full count={1}");
Dts.Events.FireError(0, "Dat file loading", msg, string.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
Dts.Variables["IsValidated"].Value = true;
Dts.TaskResult = (int)ScriptResults.Success;
}
その後、データフローがあります。スクリプト タスクをデータ フローに接続し、コネクタを右クリックして、次のように編集および構成に移動します。

SSIS パッケージは次のようになります。

お役に立てれば!