OK, so yesterday I posted an article about how standards should be followed and the dire consequences for everyone if they aren't. OK, OK, it wasn't really that dark, but the point just being that I got on my little soap box yesterday and went off on a little rant after solving a problem that had me stymied for two and a half days with no help from the internet, StackExchange or my MVP cadre. I was frustrated. Of course, after posting the article, I get texts from my friends and colleagues saying "Hey C, nice rant, but you didn't really provide a clear answer to the problem in your post."
After re-reading my post, I have to agree. So I whipped the code from my Quix toolbox into a quick Gist that will hopefully save someone else the frustration in the future. 😎
The code is pretty self explanatory.
All you have to do to incorporate this into your own C# program is to include it in your project and then call the getInfoPathAttachments() method while passing it two arguments.
The first is the XML document constituting the InfoPath form's XML which is easily loaded to the standard System.Xml.XmlDocument object.
The second is the node path where the attachments are located in your form. In my case, the control was called "Attachment" and was literally hanging straight off the root of the document so my node path was "/my:myFields/my:Attachment".
The method will return a list of MemoryStream objects which you can then process any way you like such as saving to disk or processing further etc.
Happy coding.
C
The SharePoint Knowledge Collection of Cornelius J. van Dyk, an 9 x SharePoint MVP
Subscribe to:
Post Comments (Atom)
SharePoint Remote Event Receivers are DEAD!!!
Well, the time has finally come. It was evident when Microsoft started pushing everyone to WebHooks, but this FAQ and related announcement...
-
Ever wondered what the new SharePoint Online URLs are all about? Take for example https://cjvandyk.sharepoint.us/:x:/r/sites/Site1... What ...
-
Every so often, you run across the need to redirect a page somewhere else, like after a server migration when DNS isn’t used. By simply addi...
-
When using NuGet, we can easily run into assembly reference issues. A notorious error message is: CS0012: The type ‘System.Object’ is def...
No comments:
Post a Comment
Comments are moderated only for the purpose of keeping pesky spammers at bay.