Removes the contents of the Directory and reinitializes it.
public void Reset(string destinationFolder)
Public Sub Reset( _ByVal destinationFolder As String _)
public:void Reset(String^ destinationFolder)
destinationFolder
The name of an existing destination folder in which to save the DICOMDIR File.
When an object of the DicomDir class is created, the DICOM Directory, as specified by the object, is empty. To revert to this case at any time, call the method Reset. If the same object is to be used to create the DICOM Directory of a new file-set, this method must be called first. This method also sets the destination folder of the DICOMDIR File. Please note that although the method can be passed a null reference (Nothing in VB), no DICOM file can be added to the DICOM Directory unless this folder is specified.
using Leadtools;using Leadtools.Dicom;public class MyDicomDir : DicomDir{public MyDicomDir(string destinationFolder, string path) : base(destinationFolder, path) { }public override DicomDirInsertFileCommand OnInsertFile(string fileName, DicomDataSet ds, DicomDirInsertFileStatus status, DicomExceptionCode code){if (status == DicomDirInsertFileStatus.PreAdd){string msg = string.Format("About to add the file '{0}'{1}{1}Proceed?", fileName, Environment.NewLine);DialogResult result = MessageBox.Show(msg, "Sample", MessageBoxButtons.YesNoCancel);if (result == DialogResult.Yes)return DicomDirInsertFileCommand.Continue;else if (result == DialogResult.No)return DicomDirInsertFileCommand.Skip;else if (result == DialogResult.Cancel)return DicomDirInsertFileCommand.Stop;}else if (status == DicomDirInsertFileStatus.Success){string msg = string.Format("The file '{0}' has been added successfully.", fileName);}return DicomDirInsertFileCommand.Continue;}};public void CreateDicomDirectory(){//Make sure to initialize the DICOM engine, this needs to be done only once//In the whole applicationDicomEngine.Startup();using (MyDicomDir dicomDir = new MyDicomDir(null, null)){bool autoSearch = true;// Set the destination folderdicomDir.Reset(Path.Combine(LEAD_VARS.ImagesDir, @"TEMP\DCMTEST\PATIENT1"));// Set the File-set IdentifierdicomDir.SetFileSetId("SOME ID");// Set some optionsDicomDirOptions options = dicomDir.Options;dicomDir.ResetOptions();options.IncludeSubfolders = true;options.InsertIconImageSequence = false;options.RejectInvalidFileId = true;dicomDir.Options = options;// Set the File-set descriptor filedicomDir.SetDescriptorFile(Path.Combine(LEAD_VARS.ImagesDir, @"TEMP\DCMTEST\PATIENT1\README"), null);if (autoSearch){try{dicomDir.InsertFile(null);}catch (Exception ex){MessageBox.Show(ex.GetType().ToString(), ex.Message, MessageBoxButtons.YesNoCancel);}}else{// Load a Data Set and add it to the Directoryusing (DicomDataSet ds = new DicomDataSet()){ds.Load(Path.Combine(LEAD_VARS.ImagesDir, @"TEMP\DCMTEST\PATIENT1\Image1"), DicomDataSetLoadFlags.None);dicomDir.InsertDataSet(ds, Path.Combine(LEAD_VARS.ImagesDir, @"TEMP\DCMTEST\PATIENT1\IMAGE1"));}// Add some DICOM files to the DirectorydicomDir.InsertFile(Path.Combine(LEAD_VARS.ImagesDir, @"TEMP\DCMTEST\PATIENT1\IMAGE2"));dicomDir.InsertFile(Path.Combine(LEAD_VARS.ImagesDir, @"TEMP\DCMTEST\PATIENT1\IMAGE3"));dicomDir.InsertFile(Path.Combine(LEAD_VARS.ImagesDir, @"TEMP\DCMTEST\PATIENT1\IMAGE4"));}// Test the DataSetDicomElement first = dicomDir.DataSet.FindFirstElement(null, DicomTag.PatientID, false);MessageBox.Show(first.Length.ToString());// Save the DICOMDIR FiledicomDir.Save();//We can now call something like this to call the DICOMDIR back//dicomDir.Load(LeadtoolsExamples.Common.ImagesPath.Path + @"TEMP\DCMTEST\PATIENT1\DICOMDIR",DicomDataSetLoadFlags.LoadAndClose);}DicomEngine.Shutdown();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.DicomPublic Class MyDicomDir : Inherits DicomDirPublic Sub New(ByVal destinationFolder As String, ByVal path As String)MyBase.New(destinationFolder, path)End SubPublic Overrides Function OnInsertFile(ByVal fileName As String, ByVal ds As DicomDataSet, ByVal status As DicomDirInsertFileStatus,ByVal code As DicomExceptionCode) As DicomDirInsertFileCommandIf status = DicomDirInsertFileStatus.PreAdd ThenDim msg As String = String.Format("About to add the file '{0}'{1}{1}Proceed?", fileName, Environment.NewLine)Dim result As DialogResult = MessageBox.Show(msg, "Sample", MessageBoxButtons.YesNoCancel)If result = DialogResult.Yes ThenReturn DicomDirInsertFileCommand.ContinueElseIf result = DialogResult.No ThenReturn DicomDirInsertFileCommand.SkipElseIf result = DialogResult.Cancel ThenReturn DicomDirInsertFileCommand.StopEnd IfElseIf status = DicomDirInsertFileStatus.Success ThenDim msg As String = String.Format("The file '{0}' has been added successfully.", fileName)End IfReturn DicomDirInsertFileCommand.ContinueEnd FunctionEnd ClassPrivate Sub CreateDicomDirectory()'Make sure to initialize the DICOM engine, this needs to be done only once'In the whole applicationDicomEngine.Startup()Dim dicomDir As MyDicomDir = New MyDicomDir(Nothing, Nothing)Using (dicomDir)Dim autoSearch As Boolean = True' Set the destination folderdicomDir.Reset(Path.Combine(LEAD_VARS.ImagesDir, "TEMP\DCMTEST\PATIENT1"))' Set the File-set IdentifierdicomDir.SetFileSetId("SOME ID")' Set some optionsDim options As DicomDirOptions = dicomDir.OptionsdicomDir.ResetOptions()options.IncludeSubfolders = Trueoptions.InsertIconImageSequence = Falseoptions.RejectInvalidFileId = TruedicomDir.Options = options' Set the File-set descriptor filedicomDir.SetDescriptorFile(Path.Combine(LEAD_VARS.ImagesDir, "TEMP\DCMTEST\PATIENT1\README"), Nothing)If autoSearch ThenTrydicomDir.InsertFile(Nothing)Catch ex As ExceptionMessageBox.Show(ex.GetType().ToString(), ex.Message, MessageBoxButtons.YesNoCancel)End TryElse' Load a Data Set and add it to the DirectoryDim ds As DicomDataSet = New DicomDataSet()Using (ds)ds.Load(Path.Combine(LEAD_VARS.ImagesDir, "TEMP\DCMTEST\PATIENT1\Image1"), DicomDataSetLoadFlags.None)dicomDir.InsertDataSet(ds, Path.Combine(LEAD_VARS.ImagesDir, "TEMP\DCMTEST\PATIENT1\IMAGE1"))End Using' Add some DICOM files to the DirectorydicomDir.InsertFile(Path.Combine(LEAD_VARS.ImagesDir, "TEMP\DCMTEST\PATIENT1\IMAGE2"))dicomDir.InsertFile(Path.Combine(LEAD_VARS.ImagesDir, "TEMP\DCMTEST\PATIENT1\IMAGE3"))dicomDir.InsertFile(Path.Combine(LEAD_VARS.ImagesDir, "TEMP\DCMTEST\PATIENT1\IMAGE4"))End If' Test the DataSetDim first As DicomElement = dicomDir.DataSet.FindFirstElement(Nothing, DicomTag.PatientID, False)MessageBox.Show(first.Length.ToString())' Save the DICOMDIR FiledicomDir.Save()'We can now call something like this to call the DICOMDIR back'dicomDir.Load(@LeadtoolsExamples.Common.ImagesPath.Path + "TEMP\DCMTEST\PATIENT1\DICOMDIR",DicomDataSetLoadFlags.LoadAndClose);End UsingDicomEngine.Shutdown()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
