←Select platform

CreateAttachmentStream Method


Creates a stream to the attachment file binary data.

public Stream CreateAttachmentStream( 
   int attachmentNumber, 
   ObjectCache cache 
Public Function CreateAttachmentStream( 
   ByVal attachmentNumber As Integer, 
   ByVal cache As ObjectCache 
) As Stream 
   Stream^ CreateAttachmentStream( 
      Int32 attachmentNumber, 
      ObjectCache^ cache 



1-based attachment number in this LEADDocument. This DocumentAttachments collection must contain an item with DocumentAttachment.AttachmentNumber equal to this value, otherwise an exception is thrown.


Cache object to use. This is optional, see the Remarks section.

Return Value

Stream to the attachment file binary data if successful; otherwise, null. The application program must close (dispose) the stream after use.


CreateAttachmentStream works as follows:

  1. Obtains the DocumentAttachment object identified by attachmentNumber.
  2. If the value of DocumentAttachment.DocumentId is not null, then it is assumed that the attachment document exists in the cache, and a stream to its data is created and returned.
  3. Otherwise, if the value of DocumentAttachment.IsEmbedded is true then it is assumed that the attachment is embedded in the owner document, and a stream to its data is created and returned.
  4. If all of the above fails, then null is returned.

In all cases, it is the application program's responsibility to dispose the stream returned by this method.

For more information, refer to Document Attachments.


For an example, refer to DocumentAttachment.

Target Platforms
Help Version 21.0.2021.3.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly