Create zip file in infopath - InfoPath Dev
in

InfoPath Dev

Create zip file in infopath

Last post 07-14-2008 10:42 AM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 06-24-2008 10:25 PM

    Create zip file in infopath

     Hi All,

    I am using file attachment control in my infopath form. Using this control I am browsing to a file.

    can anybody tell me how to make that file as a zip file and embed it into the same infopath form?

    I am using  infopath 2007 and programming language is C#.

     

    Thanks,

    Jaimin 

     

    Filed under:
  • 06-26-2008 03:02 PM In reply to

    Re: Create zip file in infopath

    You will need an API for creating a ZIP file... which, there might be a free one, or you might have to pay for one.

    Once you've created the ZIP in memory, convert it to a BASE64 string, and set that BASE64 string as the value of the node to which the attachment control is bound.

  • 06-29-2008 11:41 PM In reply to

    Re: Create zip file in infopath

     First I am attaching a file through file attachment control.

    than on button click I am using "Convert.FromBase64String(fileName)" , where fileName is the encoded form of the attached file.

    After this I am getting the file name as string and file contents as byte[].

    For zip I am adding "Ionic.Utils.Zip" as reference , which is a dotnetzip library.

    This are the lines I use to create a zip file:

    ....

    ZipFile zip = new ZipFile();
    zip.AddFile(fileName);
    zip.Save("C:\\ZipFiles\\Test.zip");

    ... 

     

    I am getting the zip file as "Test.zip" . From here onwards the problem starts. How will I attach "Test.zip" to my infopath form??

    plz correct me if my method is wrong and help me in meeting my requirements.

     

    Thanks.

    Jaimin 

  • 07-14-2008 10:42 AM In reply to

    Re: Create zip file in infopath

    If you are satisfied that you are correctly generating and saving a .ZIP file, and that the saved file works as expected, then you are half way there.

    You will at this point, either convert the in-memory copy of the ZIP file (if possible) or read in the saved ZIP file as a binary, and then convert that to BASE64.

    Once you've got the binary ZIP file convert to Base64, you simply set this Base64 string as the value of the node to which you attachment control is bound.

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