Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Script Task insert into Object Variable (C#)

Author  Topic 

abj84
Starting Member

1 Post

Posted - 2014-05-29 : 15:57:59
Hi guys,

I'm running a script task to scan a folder for two types of files, and depending on the citeria,
the current file the for each loop is on, that file's name will be added to one of two
object variables: A or B.

What I am trying to do is store a collection of file names into my objects
and use them as enumerators in my For Each Loops containers after this script task.

The issue is I do not know how I can add each current file name into my ObjectVariables.
The syntax below is incorrect and I'm not sure what to do.

//Simplified code:
foreach (string file in files)
{
FileInfo CurrentFile = new FileInfo(file);

if (case A)
Dts.Variables["ObjectVariableA"] += CurrentFile.Name.ToString();

else
Dts.Variables["ObjectVariableB"] += CurrentFile.Name.ToString();
}

Any help is greatly appreciated. Thank you for looking!
   

- Advertisement -