Copy attachments form SharePoint List to InfoPath Form - InfoPath Dev
in

InfoPath Dev

Copy attachments form SharePoint List to InfoPath Form

Last post 08-19-2011 01:19 AM by Karsten Brocksieper. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-10-2011 11:45 AM

    Copy attachments form SharePoint List to InfoPath Form

    Hello everyone,

               I am trying to extract attachments form SharePoint list to the infopath browser form. I found lots of article on how to copy attachments form Form to the SharePoint list but not form List to the form. I would greatly appreciate any help on this. Thank you in advance.

  • 08-19-2011 01:19 AM In reply to

    Re: Copy attachments form SharePoint List to InfoPath Form

    Hello Aerial11,

    I guess you have a valid URL for your document which you will attach to your Infopath form. Then you can accomplish this in two steps. In the first step you have to "stream" the file from your document library and in the second step you attach this "stream" to the attachment control in the form...

    Even though I have not a complete example but I have a few lines of code which will help you to get started.

    Extract a file from a document library:

    SPSite site = new SPSite(http://YourServer/YourSite);
    SPWeb web = site.OpenWeb();

    SPFile file = web.GetFile(@http://YourServer/YourSite/YourDocLibrary/Document.doc);
    System.IO.StreamReader str = new System.IO.StreamReader(file.OpenBinaryStream());

    Attach (=Encode the file) to your file attachment control

    http://support.microsoft.com/kb/2517906

    With the encoder class in this article you can use the 'stream' from step 1 to add the file to your infopath form.

    Hope you will find useful tips

    Regards,

    Karsten
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.