I have a For Each Loop container where I process files that arrive nightly. I have three user variables defined: FolderPath ("I:\Data Analytics\Referral"), FileName (blank) -- read only variables, FileExistsFlg -- ReadWriteVariables. The first two are strings and the last one is an int. I have added "using System.IO;" to my Namespaces.The value for the FileExistsFlg is 0 -- the default value when I added the variable.
Here is my C# code:
public void Main()
// TODO: Add your code here
String FilePath = Dts.Variables["User::FolderPath"].Value.ToString() +Dts.Variables["User::FileName"].Value.ToString();
if ( File.Exists(FilePath))
Dts.Variables["User::FileExistsFlg"].Value = 1;
Dts.TaskResult = (int)ScriptResults.Success; }
The task executes, but it always returns a value of 0 when in fact there are files. I'm using MessageBox.Show(. . . .) to test the script.
This doesn't strike me as rocket science and I'm mystified why it keeps returning a false value.