I had a post earlier for counting files in a folder, but it was DOS and could be called from a process task...that's really not the way that I'd do it I guess, so don't use that example. I see plenty of hits for folks searching and looking at that page, so I offer up this as an alternate. If I were tasked to do this in SSIS I'd probably use something like the following.
Crack open SSIS, add a Script Task to the Control Flow, create two SSIS variables, one called Folder of type string, and another named Count of type integer, and then add this code to the script task:
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;
namespace CountFilesInFolder
{
[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 foldername;
int count;
foldername = Dts.Variables["Folder"].Value.ToString();
count = Directory.GetFiles(foldername).Length;
MessageBox.Show(count.ToString());
Dts.Variables["Count"].Value = count;
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}
Directory.GetFiles(foldername).Length will count files for you in .Net/c# probably as good as any method, so use this and not the garbage that I posted in the other blog. Remember, I geek here, so take this stuff (including this post) at face-value.
Thanks,
Lee
----------------------------
MELINDA - Well, I just thought I'd give you them. I liked walkin' with you. I got a blister the size of a quarter on one heel. Well, I'll see you sometime, I guess. (She walks to the door and stops as if she expects Karl to say something.)
KARL - A blister shore can hurt.

d4edab7e-8e1f-4038-867a-39cf2a27c419|0|.0