user20907
user20907

Reputation: 83

Check for multiple missing files in VB.Net

I process around 10 files each day and the naming convention of the files are MMDDYY_FileName.

I currently have a SSIS package to load these files but I don’t have anything in place that tells me if any of the files missing.

I want to be able to send an email if any of the files are missing with the missing file names included in the email.

I know how to write a simple vb.net code for checking a single file but not sure how I can check for multiple files and store the missing file names.

Can someone please provide me an example of checking two or more missing files?

Below is the code I have so far for checking a single file:

If (File.Exists(CStr(Dts.Variables("filePath").Value))) Then
  Dts.TaskResult = Dts.Results.Success
Else
  Dts.TaskResult = Dts.Results.Failure

Upvotes: 1

Views: 173

Answers (1)

Robert Harvey
Robert Harvey

Reputation: 180788

Dim lst As New List(Of String) From {"path1", "path2", "..."}

Dim result as Boolean = True
For Each item As String In lst
    If not File.Exists(item) Then
        result = False
        Exit For
    End If
Next

Dts.TaskResult = Result

Upvotes: 1

Related Questions