Link to home
Start Free TrialLog in
Avatar of srionline2k6
srionline2k6Flag for United States of America

asked on

need help with vb Script for checking if file exists using script task in ssis

Hi i am writing a script task in ssis. I need assistance in writing the script task. i googled it as i am newbie to scripting, i need help. So here is the code i got. but the thing is I dont want to hard code the file name because there are four files that exists with different numbers on it with the timestamp on it for that particular day. Can I do that at the point of file location in this script without hardcoding the file. i check this code but its poping up a window. I don't want to see any pop window instead send an email to concerned using send mail task in ssis. Suggest me how can I go about it and how do i know if files doesnt exist. if doesn't exist send an email that says doesnt exist .. Please help me in writing


using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO; 

namespace ST_d4b3389a51734caa85bb7d3b9a843c90.csproj
{
  [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
  public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
  {

    #region VSTA generated code
    enum ScriptResults
    {
      Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
      Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    };
    #endregion

    

    public void Main()
    {

      //USe your folder and file name here to check if exists

      if (File.Exists(@"D:\\YOURFILEFOLDER\\Test.txt"))       -- [b]I need to check if four files are added dynamically or using wild card like * to imply that four files exists...[/b]
      {
        Dts.Variables["FileExtFlag"].Value = 1;
        MessageBox.Show(Dts.Variables["FileExtFlag"].Value.ToString()); //comment out this line, just for testing the value of variable
      }
      else
      {
        Dts.Variables["FileExtFlag"].Value = 0;
        MessageBox.Show(Dts.Variables["FileExtFlag"].Value.ToString()); //comment out , just to check value
      }
      // TODO: Add your code here
      Dts.TaskResult = (int)ScriptResults.Success;
    }
  }
}

Open in new window

Avatar of sarabande
sarabande
Flag of Luxembourg image

from the ".csproj" in namespace it seems it is c# code.

Sara

Avatar of srionline2k6

ASKER

Where I need to look my question. I haven't got any replies yet Let mw know where can i get replies
ASKER CERTIFIED SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial