Delete, remove, or clear an attachment from an InfoPath form
Learn how you can delete or clear an attachment field on an InfoPath form manually or through code.
In InfoPath, if you want to delete an attached file, you could:
- Remove the InfoPath file attachment manually; or
- Clear the attachment field programmatically.
To delete an attachment manually:
- Click on the paperclip icon in front of the attachment field.
- Select Remove from the context menu that appears.
To delete an attachment through code:
- Add an event handler to the InfoPath form template.
- Add code similar to the following to the event handler:
XPathNavigator root = MainDataSource.CreateNavigator();
XPathNavigator attachment = root.SelectSingleNode(
Note: my:attachment represents the File Attachment control on the InfoPath form.
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.