Decompiling chm files using C#
Filed Under (c#) by The Chef on 25-04-2009
Tagged Under : chm, decompile
Recently I've came across an issue: reformatting a chm file or better, converting it to a pdf. So, what's better than your own softwareAfter some research over the net, I've came with this solution:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using RelatedObjects.Storage; namespace CHMdecompiler { class Program { static void Main(string[] args) { ITStorageWrapper iw = new ITStorageWrapper(@"c:\WINDOWS\Help\blutooth.chm"); // Loop through collection of objects stored inside IStorage foreach (RelatedObjects.Storage.IBaseStorageWrapper.FileObjects.FileObject fileObject in iw.foCollection) { // Check to make sure we can READ stream of an individual file object if (fileObject.CanRead) { Console.WriteLine("Path: " + fileObject.FilePath); Console.WriteLine("File: " + fileObject.FileName); // FileUrl - is a external reference to the internal object // allows you to display content of single file in Internet Explorer // without extracting content from the archive Console.WriteLine("Url: " + fileObject.FileUrl); // We only want to extract HTM files in this example // fileObject is our representation of internal file stored in IStorage if (fileObject.FileName.EndsWith(".htm")) { //string fileString = fileObject.ReadFromFile(); //Console.WriteLine("Text: " + fileString); // Direct Extraction sample fileObject.Save(fileObject.FileName); } } } Console.ReadKey(); } } }Download [IStorage wrapper]