Hi,
I briefly looked through the source code of fo-dicom project and have found the following:
Class FileByteSource has the private BinaryReader _reader; private Stream _stream; fields which allocates unmanaged resources and supports IDisposable interface for deterministic resource releasing but I have not found any code where FileByteSource class releases these resources via using statement or explicitly closing the streams/readers.
I have not dug deeper into the codebase but just unreleased streams leads to this error in external application
class Program {
public static void Main () {
var dicomFile = DicomFile.Open("c:\filename.dcm");
var creationDate = dicomFile.Dataset.Get<DateTime>(DicomTag.CreationDate);
/*here on File.Move I continuously get IOException 'The process cannot access the file because it is being used by another process.'*/
/* Uncomment these code to allow the pure .NET hack to get rid of exception
GC.Collect();
GC.WaitForPendingFinalizers(); Finalize the opened streams and releases the underlying unmanaged resources
*/
File.Move(@"c:\filename.dcm","c:\temp\filename.dcm")
}}
Could you please give some guidelines how to use objects of DicomFile class correctly to avoid locking the dcm file which is opened
and /or give a hint to API in "FO-Dicom" library to release the resource allocated by DicomFile in deterministic way.
Thank you in advance.
PS: This library is the most advanced and powerful DICOM library which I have ever used.
Thank you for amazing project.