Skip to main content

How to Check if an Attachment Exists

  • To check whether a document contains a certain attachment,
    use the method Exists() from the Advanced.Attachments session operations.

  • Calling 'Exists' does not Load the document or the attachment to the session,
    and the session will not track them.

  • In this page:

Check if attachment exists

bool exists = session
.Advanced
.Attachments
.Exists("categories/1-A", "image.jpg");

if (exists)
{
// attachment 'image.jpg' exists on document 'categories/1-A'
}

Syntax

bool Exists(string documentId, string attachmentName);
ParameterTypeDescription
documentIdstringThe ID of the document you want to check
attachmentNamestringThe name of the attachment you are looking for
Return ValueDescription
booltrue - The specified attachment exists on the document
false - The attachment does not exist on the document