Script task file check error
in ssis package using script task check whether file exists or not.
i having 3 variable below
user::v_filepath >file path
user::v_geographylevelfilename >filename
user::v_fileexistsflg >flag
below code using same
string filepath = dts.variables["user:v_filepath"].value.tostring() + dts.variables["user::v_geographylevelfilename"].value.tostring();
if (
file.exists(filepath)
)
{
dts.variables["user::v_fileexistsflg"].value = 1;
}
messagebox.show(filepath);
messagebox.show(dts.variables["user::v_fileexistsflg"].value.tostring());
dts.taskresult = (int)scriptresults.success;
but getting exception error.
find attached screenshot of error
thankx & regards, vipin jha mcp
there few areas need check.
1. add namespace, system.io
#region namespaces
using system;
using system.data;
using microsoft.sqlserver.dts.runtime;
using system.windows.forms;
using system.io;
#endregion
2. set datatype of variables below
user::v_filepath >string
user::v_geographylevelfilename >string
user::v_fileexistsflg >int32
3. set path , filename below. note "\" character @ end of path.
user::v_filepath >c:\testfolder\
user::v_geographylevelfilename >test.txt
4. paste below code,
string filepath = dts.variables["user::v_filepath"].value.tostring() + dts.variables["user::v_geographylevelfilename"].value.tostring(); if (file.exists(filepath)) { dts.variables["user::v_fileexistsflg"].value = 1; } dts.taskresult = (int)scriptresults.success;
regards, rsingh
SQL Server > SQL Server Integration Services
Comments
Post a Comment