←Select platform

Reset Method

Summary
Removes the contents of the Directory and reinitializes it.
Syntax
C#
Objective-C
C++/CLI
public void Reset( 
   string destinationFolder 
) 
- (void)reset:(NSString *)destinationFolder; 
public: 
void Reset(  
   String^ destinationFolder 
)  

Parameters

destinationFolder
The name of an existing destination folder in which to save the DICOMDIR File.

Remarks

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.

Example
C#
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); 
         Console.WriteLine($"{msg}"); 
         return DicomDirInsertFileCommand.Continue; 
 
      } 
      else if (status == DicomDirInsertFileStatus.Success) 
      { 
         string msg = string.Format("The file '{0}' has been added successfully.", fileName); 
         Console.WriteLine(msg); 
      } 
      return DicomDirInsertFileCommand.Continue; 
   } 
}; 
 
public void CreateDicomDirectory() 
{ 
   //Make sure to initialize the DICOM engine, this needs to be done only once  
   //In the whole application 
   DicomEngine.Startup(); 
   using (MyDicomDir dicomDir = new MyDicomDir(null, null)) 
   { 
      bool autoSearch = true; 
      // Set the destination folder 
      dicomDir.Reset(Path.Combine(LEAD_VARS.ImagesDir, @"TEMP\DCMTEST\PATIENT1")); 
      // Set the File-set Identifier 
      dicomDir.SetFileSetId("SOME ID"); 
      // Set some options 
      DicomDirOptions options = dicomDir.Options; 
      dicomDir.ResetOptions(); 
      options.IncludeSubfolders = true; 
      options.InsertIconImageSequence = false; 
      options.RejectInvalidFileId = true; 
      dicomDir.Options = options; 
 
      // Set the File-set descriptor file 
      string path = Path.Combine(LEAD_VARS.ImagesDir, @"TEMP\DCMTEST\PATIENT1\README"); 
      dicomDir.SetDescriptorFile(path, null); 
 
      if (autoSearch) 
      { 
         try 
         { 
            dicomDir.InsertFile(null); 
         } 
         catch (Exception ex) 
         { 
            Console.WriteLine($"{ex.GetType().ToString()} {ex.Message}"); 
         } 
      } 
      else 
      { 
         // Load a Data Set and add it to the Directory 
         using (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 Directory 
         dicomDir.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 DataSet 
      DicomElement first = dicomDir.DataSet.FindFirstElement(null, DicomTag.PatientID, false); 
      Console.WriteLine(first.Length.ToString()); 
 
      // Save the DICOMDIR File 
      dicomDir.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:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.1.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.