DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomDataSet Class / Write Method / Write(String,String,DicomDataSet) Method

The name of the file to write.

This is passed unmodified to the operating system, and it is therefore the container�s responsibility to ensure either that the current directory is set correctly, or that a fully qualified filename is provided.

Specifies the full UID of the transfer syntax with which the file is to be saved when Part 10 format is used. If omitted, the little-endian explicit VR transfer syntax is used.

The customized MetaHeader (only Group 2 Elements)

Example

In This Topic
    Write(String,String,DicomDataSet) Method
    In This Topic
    Writes dataset to an external DICOM file with specified transfer syntax and meta header
    Syntax
    'Declaration
     
    
    Public Overloads Sub Write( _
       ByVal FileName As System.String, _
       ByVal TransferSyntax As System.String, _
       ByVal MetaHeader As DicomDataSet _
    ) 
    public void Write( 
       System.string FileName,
       System.string TransferSyntax,
       DicomDataSet MetaHeader
    )

    Parameters

    FileName

    The name of the file to write.

    This is passed unmodified to the operating system, and it is therefore the container�s responsibility to ensure either that the current directory is set correctly, or that a fully qualified filename is provided.

    TransferSyntax

    Specifies the full UID of the transfer syntax with which the file is to be saved when Part 10 format is used. If omitted, the little-endian explicit VR transfer syntax is used.

    MetaHeader

    The customized MetaHeader (only Group 2 Elements)

    Remarks

    The file may subsequently be read by the Read method or by other DICOM software.

    The provided meta header should only contain group 2 elements.

    Example
    DicomDataSet ds = new DicomDataSet();
    DicomDataSet metaHeader = new DicomDataSet();
    string filename = "Output_Dataset.dcm";
    string transferSyntax = TransferSyntaxes.ExplicitVRLittleEndian;
                        
    string pixelTransferSyntax = TransferSyntaxes.ExplicitVRLittleEndian;
    ds.Add(Keyword.SamplesPerPixel, 1);
    ds.Add(Keyword.PhotometricInterpretation, "MONOCHROME2");
    ds.Add(Keyword.Rows, 512);
    ds.Add(Keyword.Columns, 512);
    ds.Add(Keyword.PixelSpacing, new float[] { 0.684f, 0.684f });
    ds.Add(Keyword.BitsAllocated, 16);
    ds.Add(Keyword.BitsStored, 12);
    ds.Add(Keyword.HighBit, 11);
    ds.Add(Keyword.PixelRepresentation, 0);
    ds.Add(Keyword.WindowCenter, new int[] { 35, 50 });
    ds.Add(Keyword.WindowWidth, new int[] { 350, 150 });
    ds.Add(Keyword.RescaleIntercept, -1200);
    ds.Add(Keyword.RescaleSlope, 1);
    ds.SetPixelData(pixelTransferSyntax, getData);
                        
    metaHeader.Add(Keyword.MediaStorageSOPClassUID, SOPClasses.CT); // CT Image Storage
    metaHeader.Add(Keyword.MediaStorageSOPInstanceUID, DicomGlobal.NewUID());
    metaHeader.Add(Keyword.TransferSyntaxUID, transferSyntax);
    metaHeader.Add(Keyword.ImplementationClassUID, DicomGlobal.ImplementationUID);
    metaHeader.Add(Keyword.ImplementationVersionName, DicomGlobal.ImplementationName);
         
    ds.Write(filename, transferSyntax, metaHeader);
                        
    // Method
    private Stream getData(int arg)
    {
        return new FileStream("pixel.data", FileMode.Open, FileAccess.Read, FileShare.Read);
    }
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also