Reputation: 2657
I'm using a C# Script task in SSIS to check the file size of a file and compare to a variable called FileFoundSize
. This is my code:
public void Main()
{
string fullPath = Path.Combine(Dts.Variables["$Project::ValidationImport"].Value.ToString(), Dts.Variables["User::zipFileName"].Value.ToString());
var fileInfo = new FileInfo(fullPath);
if (fileInfo.Exists)
{
fileInfo.Length > Dts.Variables["User::FileFoundSize"];
Dts.TaskResult = (int)ScriptResults.Success;
}
else
{
// file could not be found
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
However, the editor keeps highlighting this line:
fileInfo.Length > Dts.Variables["User::FileFoundSize"];
And stating this error:
What am I missing?
Upvotes: 0
Views: 215
Reputation: 28771
Try with below code, you missed Value property for variable
if (fileInfo.Exists)
{
if(fileInfo.Length > Convert.ToInt32(Dts.Variables["User::FileFoundSize"].Value.ToString()))
Dts.TaskResult = (int)ScriptResults.Success;
else
Dts.TaskResult = (int)ScriptResults.Failure;
}
else
{
Dts.TaskResult = (int)ScriptResults.Failure;
}
Upvotes: 1