Hi, since last two days i tried to run package but i got stuck with one error only. In script task my file path is my source file. It catch that file which is not exists in that folder. My file path is \\sss0000111\Unit-B\Test\CSV. Error is \\sss0000111\Unit-B\Test\CSV_SUM. It tries to catch CSV_SUM file which doesn't exist in Test folder. I am stuck with this and i dont know how to solve this. File path is variable in my C# script. Please guide me for this.
using System;
using System.IO;
using System.Text;
using System.Data;
//using System.Math;
using Microsoft.SqlServer.Dts.
namespace ST_
{
[System.AddIn.AddIn("
public partial class ScriptMain :
Microsoft.SqlServer.Dts.Tasks.
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.
Failure = Microsoft.SqlServer.Dts.
};
#endregion
public void Main()
{
Dts.TaskResult = (int)ScriptResults.Success;
Boolean fireagain = false;
int taskResult;
string fileSourcePath;
string fileDestPath;
StreamReader sr;
StreamWriter sw;
string Str;
string delim = ",";
string RecordType;
// Dim FileCreateDate As Date
string LastRecordType = " ";
string FilesProcessed;
string SourceFileName;
string CurrentDate;
string FileName;
// Dim ret As Integer
CurrentDate = DateTime.Now.ToString("
Dts.Events.FireInformation(-1, "CurrentDate", CurrentDate.ToString(),String.Empty, 0, ref fireagain);
try
{
fileSourcePath = Dts.Variables["User::FilePath"
fileDestPath = Dts.Connections["CGDP_RECON"].
FilesProcessed = Dts.Variables["User::
FileName = Dts.Variables["User::FileName"
//fileSourcePath
= ReadVariable("FilePath").
//fileDestPath
= Dts.Connections["CGDP_INPUT.
//FilesProcessed
= ReadVariable("FilesProcessed")
//the value before we change it here
Dts.Events.FireInformation(-1, "fileSourcePath", fileSourcePath, String.Empty, 0, ref fireagain);
Dts.Events.FireInformation(-1, "FileName", FileName, String.Empty, 0, reffireagain);
// Dim valid As Boolean
// Dim fileID As String
// Dim contract As String
int sep;
sep = FileName.LastIndexOf("\\");//
SourceFileName
= FileName.Substring((sep + 1));//fileSourcePath.
Dts.Events.FireInformation(-1, "SourceFileName", SourceFileName, String.Empty, 0, ref fireagain);
sr = File.OpenText(fileSourcePath+
//string
test = Dts.Variables[sr].Value.
Str = sr.ReadLine();
Dts.Variables[Str].Value.