←Select platform

CreateAttachmentStream Method

Summary

Creates a stream to the attachment file binary data.

Syntax
C#
VB
C++
public Stream CreateAttachmentStream( 
   int attachmentNumber, 
   ObjectCache cache 
) 
Public Function CreateAttachmentStream( 
   ByVal attachmentNumber As Integer, 
   ByVal cache As ObjectCache 
) As Stream 
public:  
   Stream^ CreateAttachmentStream( 
      Int32 attachmentNumber, 
      ObjectCache^ cache 
   ) 

Parameters

attachmentNumber

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

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.

Remarks

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.

Example

For an example, refer to DocumentAttachment.

Requirements
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