Hi All,
I have a fairly simple requirement to read the filename from a location and populate a variable with the filename. I am using a script task for this task. No matter what I try, the value of the filename is not populating in the variable.
There is only one ReadWriteVariables which will hold the full name of the file.
Here is the script that I'm using:
namespace ST_f8fd828f11b64932b15f2681e86c8d94
{
using System;
using System.Data;
using System.IO;
using Microsoft.SqlServer.Dts.Runtime;
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
string p = "C:\\Users\\nthaku01\\Desktop\\NewEXPOLD.txt";
FileInfo fi = new FileInfo(p);
String fileName = fi.FullName;
Dts.Variables["User::vLastFilename"].Value = fileName.ToString();
MessageBox.Show(Dts.Variables["User::vLastFilename"].Value.ToString());
Dts.TaskResult = (int)ScriptResults.Success;
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
}
}
The MessageBox displays the name(and path) of the file. However, the variable in SSIS is empty
This issue has been discussed in detail previously as well and I tried every trick. However, it is just not working for me. Please help!!
Thanks,
Navneet