How to extract an xml file from a xsn file programtically RRS feed

  • Question

  • Hi,

    I want to extract InfoPath XML file from InfoPath XSN file programmatically. XML file is successfully created when I open XSN file using InfoPath manually and save the file as XML. However, when I try to extract the XSN file (assuming CAB file) programmatically nothing is displayed in XSN file. I used the following code to extract XSN file contents:

    Shell sh = new Shell();
    Folder fldr = sh.NameSpace(DestDir);
    foreach (FolderItem f in sh.NameSpace(xsnFile).Items()) fldr.CopyHere(f, 0);

    I also tried to save the XSN file as XML programmatically. However, XML file saved is encrypted and cannot be parsed.

    Any help in extracting or converting the XSN to XML file will be appreciated.

    • Edited by Abhijit PS Tuesday, September 26, 2017 1:08 PM
    Tuesday, September 26, 2017 1:08 PM

All replies

  • Try to view and analyze XML data using XML viewer
    • Edited by Jimoza Wednesday, September 27, 2017 5:07 AM
    Wednesday, September 27, 2017 5:07 AM
  • Hi Abhijit,

    For extracting files from xsn file, I suggest you try Microsoft.Deployment.Compression.Cab by following below steps.

    1. Install package Microsoft.Deployment.Compression.Cab by Manage NuGet packages.

    2. Use below code

    CabInfo cab = new CabInfo(@"xsn file path");
    cab.Unpack(@"folder to store extracted files");

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, September 27, 2017 9:59 AM