Using the DicomFileInsert Event for VB.NET
Private WithEvents DicomDir As LTDICDIRLib.LEADDicomDir
Private Sub DicomDir_DicomFileInsert(ByVal 
 bstrFileName As String, ByVal hDicomDS As Integer, ByVal nStatus As Short, 
 ByRef pReturnVal As Short)
   Dim Buffer As String
   Dim Result As DialogResult
   If nStatus = LTDicomKernelLib.DicomErrorCodes.DICOMDIR_INSERTDICOMFILE_PREADD 
 Then
      Buffer = "About to add the file 
 """ & bstrFileName & """." 
 & vbCrLf & vbCrLf & "Proceed?" 
      Result = MessageBox.Show(Buffer, "DICOM 
 Directory Sample", MessageBoxButtons.YesNoCancel)
      If Result = DialogResult.No Then
         pReturnVal = LTDicomKernelLib.DicomErrorCodes.DICOM_ERROR_FORMAT ' 
 Skip the file 
         Exit Sub
      ElseIf Result = DialogResult.Cancel 
 Then 
         pReturnVal = LTDicomKernelLib.DicomErrorCodes.DICOM_ERROR_END 
 ' Abort 
      Exit Sub 
      End If 
   ElseIf nStatus = LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS 
 Then 
      Buffer = "The file """ 
 & bstrFileName & """ has been added successfully." 
 & vbCrLf & vbCrLf & "Continue?"
      Result = MessageBox.Show(Buffer, "DICOM 
 Directory Sample",MessageBoxButtons.YesNo)
      If Result = DialogResult.No Then
         pReturnVal = LTDicomKernelLib.DicomErrorCodes.DICOM_ERROR_END 
 ' Abort 
      Exit Sub 
      End If 
   End If 
End Sub
Private Sub CreateDicomDir()
   Dim L_KEY_MEDICAL As String = ""
   DicomDir = New LTDICDIRLib.LEADDicomDir
   Dim DicomFactory As New LTDicomKernelLib.LEADDicomFactory
   Dim DicomKernel As LTDicomKernelLib.LEADDicomKernel
   Dim strLic As String 
   strLic = "LEADTOOLS OCX Copyright (c) 1991-2005 
 LEAD Technologies, Inc." DicomKernel = DicomFactory.CreateObject("LEADDicomKernel.LEADDicomKernel", 
 strLic)
   DicomKernel.UnlockSupport(LTDicomKernelLib.DicomSupportLockConstants.L_SUPPORT_MEDICAL, 
 L_KEY_MEDICAL)
   If DicomKernel.IsSupportLocked(LTDicomKernelLib.DicomSupportLockConstants.L_SUPPORT_MEDICAL) 
 Then 
      MessageBox.Show("Medical Support 
 must be unlocked for this demo!", "", MessageBoxButtons.OK, 
 MessageBoxIcon.Exclamation)
      Exit Sub 
   End If
   ' Set the destination folder
   DicomDir.ResetDicomDir("C:\Medical 
 Images")
   ' Files in subfolders should also be included
   DicomDir.IncludeSubfolders 
 = True
   ' Add all the DICOM files to the Directory
   DicomDir.InsertDicomFile("")
   ' Save the DICOMDIR File
   DicomDir.SaveDicomDir()
End Sub