I am trying to check if file exists in a folder using SSIS Script task.
If I want to send out an email stating whether the file is present, then ForEachLoop can't be used. Also, my filename is random.
Firstpart_Secondaprt.csv
FirstPart is constant while SecondPart is random.
Check the firstpart against the filename and if found matching then file exists mail is sent out. else file doesn't exist mail is send.
I used FirstPart_*.csv in the script task. But it wasn't useful.
Any suggestions on how can I achieve this in script task in ssis.
You're looking for System.IO.Directory.GetFiles(string, string)
. This will search a given path for files based on a pattern which can include wildcards.
Example usage:
var foundFilenames = Directory.GetFiles(@"C:\my\path", "FirstPart_*.csv");
You can then use this in combination with variables in your script task.