Creating a DICOM Directory for VB.NET

Private Sub CreateDicomDirectory()
   Dim L_KEY_MEDICAL As String = ""
   Dim DicomDir As 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\Patient 1")

   ' If it is desired to change the Implementation Class UID and
   ' the Implementation Version Name...
   DicomDir.ImplementationClassUID = "1.2.840.114257.0.1"
   DicomDir.ImplementationVersionName = "LEADTOOLS 14.5"

   ' Set the File-set Identifier
   DicomDir.SetFileSetID("SOME ID")

   ' We need icon images to be added
   DicomDir.InsertIconImageSequence = True

   ' Don't allow invalid File IDs
   DicomDir.RejectInvalidFileID = True

   ' Set the File-set descriptor file
   DicomDir.SetDescriptorFile("C:\Medical Images\Patient 1\ReadMe", "")

   ' Enable generating runtime exceptions
   DicomDir.EnableMethodErrors = True

   ' Add some DICOM files to the Directory
   DicomDir.InsertDicomFile("C:\Medical Images\Patient 1\Image1")
   DicomDir.InsertDicomFile("C:\Medical Images\Patient 1\Image2")
   DicomDir.InsertDicomFile("C:\Medical Images\Patient 1\Image3")

   ' Disable generating runtime exceptions
   DicomDir.EnableMethodErrors = False

   ' Save the DICOMDIR File
   DicomDir.SaveDicomDir()

End Sub