Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5987605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:50:21+00:00 2026-05-22T22:50:21+00:00

I’m working in SSIS and Visual Studio 2008. When executed, I need to have

  • 0

I’m working in SSIS and Visual Studio 2008. When executed, I need to have the SSIS package perform the following tasks:

  • Check a folder for a file
  • If a file exists take the file and use it as the source for the flat file
  • Store the name of the file into a global variable that I can access in other parts of my package

The package will be run by some other script. Thus we need it to check for the file every time the package runs. We are trying to prevent the scenario where we have to monitor the folder and execute the package manually when the file appears.

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:50:22+00:00Added an answer on May 22, 2026 at 10:50 pm

    The easiest way would be to set up a Foreach Loop container that has all the “work” of your package inside of it (optionally, you can it as a precursor step and use a conditional expression off of it). Assuming you have 2 variables called FileName (which is what you will have the value assigned to) and an InputFolder variable that contains the “where” we should be looking

    ForEach Loop Editor
    
    Collection tab:  
    Enumerator = Foreach File Enumerators
    Expression: Directory = @[User:InputFolder]
    FileSpec: "YD.*"
    
    Retrieve file name
    * Fully qualified
    
    Variable Mappings tab:  
    Variable: User::FileName 
    Index:  0
    

    Collection Tab
    Variable Mappings Tab

    You can also do this via a script task, if you’d like to see that, let me know.

    EDIT
    This script again assumes you have the variables InputFolder and FileName defined. Create a Script Task Component and check InputFolder as a read only variable, FileName as a read/write variable.

    using System;
    using System.Data;
    using System.IO;  // this needs to be added
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    
    // namespace will vary 
    namespace ST_bc177fa7cb7d4faca15531cb700b7f11.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()
            {
                string inputFolder;
                string fileName;
                inputFolder = Dts.Variables["InputFolder"].Value.ToString();
    
                // File, if exists will look like YD.CCYYMMDD.hhmmss.done
                string fileMask = "YD.*.done";
    
                // this array will catch all the files matching a given pattern
                string[] foundFiles = null;
                foundFiles = System.IO.Directory.GetFiles(inputFolder, fileMask);
    
                // Since there should be only one file, we will grab the zeroeth
                // element, should it exist
                if (foundFiles.Length > 0)
                {
                    fileName = foundFiles[0];
    
                    // write the value to our global SSIS variable
                    Dts.Variables["FileName"].Value = fileName;
                }
    
                Dts.TaskResult = (int)ScriptResults.Success;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.