Skip to content

Instantly share code, notes, and snippets.

@cjvandyk
Created December 12, 2018 21:01
Show Gist options
  • Save cjvandyk/25dcae339a3f99325fd67fa913203f79 to your computer and use it in GitHub Desktop.
Save cjvandyk/25dcae339a3f99325fd67fa913203f79 to your computer and use it in GitHub Desktop.
Save decoded attachment
//Create an XmlNamespaceManager
XmlNamespaceManager ns = this.NamespaceManager;
//Create an XPathNavigator object for the Main data source
XPathNavigator xnMain = this.MainDataSource.CreateNavigator();
//Create an XPathNavigator object for the attachment node
XPathNavigator xnAttNode = xnMain.SelectSingleNode("/my:myFields/my:theAttachmentField", ns);
//Obtain the text of the node.
string theAttachment = xnAttNode.Value;
if(theAttachment.Length > 0)
{
InfoPathAttachmentDecoder myDecoder = new InfoPathAttachmentDecoder(theAttachment);
myDecoder.SaveAttachment(@"Path to the folder to save the attachment");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment