Attachment Encoder and Decoder - InfoPath Dev
in

InfoPath Dev

Attachment Encoder and Decoder

Last post 02-09-2010 11:41 PM by Lawson. 25 replies.
Page 2 of 2 (26 items) < Previous 1 2
Sort Posts: Previous Next
  • 02-09-2010 06:50 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    You are AWESOME!!!

    Thank you!

    I followed all of your directions, and the save button works.

    Thanks for all your help

    -Lawson

  • 02-09-2010 06:52 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    Yeah I know. I was following all of her directions and testing it. I posted that last post before I saw your response. You're AWESOME man. Thanks for all of your help

  • 02-09-2010 07:44 PM In reply to

    Re: Attachment Encoder and Decoder

     No worries.  Glad it helped :-)

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-09-2010 08:11 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    Can I add more attachment fields to the save button, or do I need to add another save button?

     Thanks

    -Lawson

  • 02-09-2010 08:44 PM In reply to

    Re: Attachment Encoder and Decoder

     The button's code can do as much or as little as you want it to do.  You just need to figure out a design that makes sense.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-09-2010 08:47 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    I tried to alter the button with the following code.

     

    [InfoPathEventHandler(MatchPath = "btnSave", EventType = InfoPathEventType.OnClick)]public void btnSave_OnClick(DocActionEvent e)

    {

    //Get a reference to the attachment node.

    IXMLDOMNode n = thisXDocument.DOM.selectSingleNode("my:myFields/my:theAttachmentField");

    //Get the text of the node.

    String theAttachment = n.text;if (theAttachment.Length > 0)

    {

    InfoPathAttachmentEncoding.InfoPathAttachmentDecoder myDecoder = new InfoPathAttachmentEncoding.InfoPathAttachmentDecoder(theAttachment);

    myDecoder.SaveAttachment(@"C:\Users\Lawson\Documents\InfoPath Forms");

    }

    //Get a reference to the attachment node.

    IXMLDOMNode nn = thisXDocument.DOM.selectSingleNode("my:myFields/my:theAttachmentField2");

    //Get the text of the node.

    String theAttachment2 = n.text;if (theAttachment.Length > 0)

    {

    InfoPathAttachmentEncoding.InfoPathAttachmentDecoder myDecoder = new InfoPathAttachmentEncoding.InfoPathAttachmentDecoder(theAttachment2);

    myDecoder.SaveAttachment(@"C:\Users\Lawson\Documents\InfoPath Forms");

    }

     

    However, only the contents of theAttachment is saved when I press the save button.

    Is my approach completely wrong?

     

    -Lawson

     

     

  • 02-09-2010 09:12 PM In reply to

    Re: Attachment Encoder and Decoder

     This line should have nn.text, not n.text, and theAttachment2, not theAttachment:

    String theAttachment2 = n.text;if (theAttachment.Length > 0)

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-09-2010 10:02 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    When I made the changes, the code passed through the debugger. However, when I tried to save the attachments I received the following.

    NullReferenceException was unhandled by user codeTroubleShooting tips:Use the “new” keyword to create an object instance

    For this line,

    String theAttachment2 = nn.text;

  • 02-09-2010 10:20 PM In reply to

    Re: Attachment Encoder and Decoder

     Could it be that you don't actually have a field in your data source with this path?:

     my:myFields/my:theAttachmentField2

     Or perhaps there's a capitalization mistake somewhere (either in the way you named the field, or in that path there).

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-09-2010 10:32 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    Yeah, I caught that mistake right after I sent the last post.

    I made the appropriate changes, but I still get the previously mentioned problem when I click the save button.

    I checked for a capitalization mistake throughout the code, but I didn't find a mistake.

    Do you know why the debugger suggests using the keyword "new"?

  • 02-09-2010 11:41 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    Thanks for all your help man.

    I'm gonna call it a night.

    I'll probably just create a new post tomorrow with this new problem as the subject.

    -Lawson

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