Attach zip file to infopath form - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Attach zip file to infopath form

Last post 10-29-2009 12:12 PM by zlatan24. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 10-07-2008 03:49 AM

    Attach zip file to infopath form

    Hi All,

    I am using infopath 2007. 

    In my sharepoint form library, I have an infopath form which has an attachment field.

    This is my requirement --> On button click, I need to programmatically attach a zip file to that attachment field.

    I know attachments in infopath are stored in base64 encoded string.

    Till now I am successfully able to load the zip file into byte[] array and convert it into base64 string. This is the code snippet:

                    string strFilePath = "C:\\";
                    FileStream fs = new FileStream(strFilePath, FileMode.Open, FileAccess.Read);
                    BinaryReader br = new BinaryReader(fs);

                    byte[] data = new byte[fs.Length];
                    fs.Read(data, 0, data.Length);

                    string strBase64 = Convert.ToBase64String(data);

     After this how do I set the value of infopath attachment field as strBase64??

     Is this is the right approach or am I going wrong??

    Need help.



    Filed under:
  • 10-07-2008 07:36 AM In reply to

    Re: Attach zip file to infopath form

    Hi there:

    First off, please check out this KB article for information on encoding and decoding. It will help you with things like setting the file name. To select a node and set the value, you can use the following, changing the xpath to point to your node:

    string xpath = "/my:myFields/my:field1";
    XPathNavigator node = MainDataSource.CreateNavigator().SelectSingleNode(xpath, this.NamespaceManager);
    Hilary Stoupa

  • 10-08-2008 05:08 AM In reply to

    Re: Attach zip file to infopath form

     thanks for the help. I'll try this and let you know if it works or not.




    Filed under:
  • 10-13-2008 12:38 AM In reply to

    Re: Attach zip file to infopath form

     Thanks Hilary.

     file attachment is working now.



  • 10-29-2009 12:12 PM In reply to

    Re: Attach zip file to infopath form

    For work with zip files I prefer to use-fix windows zip on vista-on next reason.Once I saw that all my zip files were deleted from PC.I used another programs but they couldn't help to me.And this tool solved my problems quickly and for free.

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