SSIS Script Task C# Only assignment and new object expressions can be used 错误
SSIS Script Task C# Only assignment and new object expressions can be used Error
我在 SSIS 中使用 C# 脚本任务来检查文件的文件大小并与名为 FileFoundSize
的变量进行比较。这是我的代码:
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;
}
}
然而,编辑一直强调这一行:
fileInfo.Length > Dts.Variables["User::FileFoundSize"];
并指出这个错误:
我错过了什么?
尝试使用以下代码,您错过了变量
的值 属性
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;
}
我在 SSIS 中使用 C# 脚本任务来检查文件的文件大小并与名为 FileFoundSize
的变量进行比较。这是我的代码:
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;
}
}
然而,编辑一直强调这一行:
fileInfo.Length > Dts.Variables["User::FileFoundSize"];
并指出这个错误:
我错过了什么?
尝试使用以下代码,您错过了变量
的值 属性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;
}