c# to extract InfoPath Attachment. - InfoPath Dev
in

InfoPath Dev

c# to extract InfoPath Attachment.

Last post 02-21-2014 08:45 AM by Jimmy. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-19-2014 12:09 PM

    c# to extract InfoPath Attachment.

    Hello everyone,

    I used the following code to extract an InfoPath attachment to a shared drive.

    public void CTRL35_5_Clicked(object sender, ClickedEventArgs e)

    {

    // Write your code here.

    XPathNavigator mainDS = MainDataSource.CreateNavigator();

    string base64EncodedString = mainDS.SelectSingleNode(

    "my:myFields/my:Attachment", NamespaceManager).Value;

    if (!String.IsNullOrEmpty(base64EncodedString))

    {

    DecoderInfoPathA.

    InfoPathAttachmentDecoder decoder =

    new DecoderInfoPathA.InfoPathAttachmentDecoder(base64EncodedString);

    System.IO.

    File.WriteAllBytes(

    @"\\Shared\Drive\Path\Here\" + decoder.Filename, decoder.DecodedAttachment);

    }

    }

    The porblem is that this code only works when the InfoPath form is in full turst and of course the governance group is never going to let tha that happen.  I'm wondering if any one knows of an alternative approach or a way to write some code that will enable just that code to run in full trust mode when the infopath form is running on the client.

    Thanks!

  • 02-21-2014 08:45 AM In reply to

    Re: c# to extract InfoPath Attachment.

    Any code that accesses a local filesystem (including shared drives) is going to require full trust, and there isn't a way to make the code "partially" full trust. Is there any chance you could instead write the files to an intranet web/SharePoint server? That should be possible from a domain trust form.

    When you say "when the infopath form is running on the client", are you saying that the form will sometimes be running on the client and sometimes on the server, or am I just reading too much into that?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.