How to VERY EASILY decompress XSN files using C#

XSN files are just cab files, but .NET doesn’t ship with APIs to easily decompress them. After a little bit of poking around I found SevenZipSharp to be the fasted and simplest way to do so.

1. Install 7-Zip
2. Download SevenZipSharp
3. Reference the SevenZipSharp DLLs in your project
4. Change your projects target platform to x86 or x64 (depending on what platform you are using). Properties, Build—>Target Platform.
5. Add these 3 lines of code to your project.

SevenZipExtractor.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");
// If this path doesn't exist then find 7z.dll on your machine and point to that.
 
SevenZipExtractor zip = new SevenZipExtractor("path to xsn");
zip.ExtractArchive("path to folder you want to decompress to");