Creating a DICOM Directory for C#
private void CreateDicomDirectory()
{
string L_KEY_MEDICAL = "" ;
LTDICDIRLib.LEADDicomDir 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\\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();
}