Using the DicomFileInsert Event for C#

private LTDICDIRLib.LEADDicomDir DicomDir;
private void DicomDir_DicomFileInsert(string bstrFileName, int hDicomDS, short nStatus, ref short pReturnVal)
{
   string Buffer = null;
   DialogResult Result = 0;
   if (nStatus == (short)LTDicomKernelLib.DicomErrorCodes.DICOMDIR_INSERTDICOMFILE_PREADD)
   {
      Buffer = "About to add the file \"" + bstrFileName + "\"." + System.Environment.NewLine + System.Environment.NewLine + "Proceed?";
      Result = MessageBox.Show(Buffer, "DICOM Directory Sample", MessageBoxButtons.YesNoCancel);
      if (Result == DialogResult.No)
      {
         pReturnVal = (short)LTDicomKernelLib.DicomErrorCodes.DICOM_ERROR_FORMAT;
         // Skip the file
         return;
      }
      else if (Result == DialogResult.Cancel)
      {
         pReturnVal = (short)LTDicomKernelLib.DicomErrorCodes.DICOM_ERROR_END;
         // Abort
         return;
      }
   }
   else if (nStatus == (short)LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS)
   {
      Buffer = "The file \"" + bstrFileName + "\" has been added successfully." + System.Environment.NewLine + System.Environment.NewLine + "Continue?";
      Result = MessageBox.Show(Buffer, "DICOM Directory Sample",MessageBoxButtons.YesNo);
      if (Result == DialogResult.No)
      {
         pReturnVal = (short)LTDicomKernelLib.DicomErrorCodes.DICOM_ERROR_END;
         // Abort
         return;
      }
   }
}

private void CreateDicomDir()
{
   string L_KEY_MEDICAL = "" ;
   DicomDir = new LTDICDIRLib.LEADDicomDir();
   LTDicomKernelLib.LEADDicomFactory DicomFactory = new    LTDicomKernelLib.LEADDicomFactory();
   LTDicomKernelLib.LEADDicomKernel DicomKernel = null;
   string strLic = null;
   strLic = "LEADTOOLS OCX Copyright (c) 1991-2005 LEAD Technologies, Inc.";
   DicomKernel = (LTDicomKernelLib.LEADDicomKernel)DicomFactory.CreateObject("LEADDicomKernel.LEADDicomKernel", strLic);
   DicomKernel.UnlockSupport((short)LTDicomKernelLib.DicomSupportLockConstants.L_SUPPORT_MEDICAL, L_KEY_MEDICAL);
   if (DicomKernel.IsSupportLocked((short)LTDicomKernelLib.DicomSupportLockConstants.L_SUPPORT_MEDICAL))
   {
      MessageBox.Show("Medical Support must be unlocked for this demo!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
      return;
   }
   // 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();
}