I have a script task in SSIS to get .xlsx file at a specific location and do some operations on the file.
My code:
public void Main()
{
// TODO: Add your code here
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
var dir = new System.IO.DirectoryInfo(FILEPATH);
var fullFilePath = dir.GetFiles("*.xlsx").Select(f => f.FullName).First();
if (fullFilePath != null)
{
//FILE OPERATIONS
}
Dts.TaskResult = (int)ScriptResults.Success;
}
When I run the code and if no .xlsx file is available at the file location, I am getting an exception. Is there a way to handle this?