Bodo
Bodo

Reputation: 127

Open CHM (help file) in C#

I'm trying to open help file (chm extension) in C#.

File.Open(@"//help.chm",FileMode.Open, FileAccess.Read, FileShare.Read);

and

FileStream fileStream = new FileStream(@"c:\help.chm", FileMode.Open);

doesn't work :(

Upvotes: 11

Views: 37694

Answers (7)

Raviraj
Raviraj

Reputation: 71

System.Diagnostics.Process.Start(@"c:\help.chm");

Upvotes: 1

Code_Worm
Code_Worm

Reputation: 4470

 Help.ShowHelp(this, AppDomain.CurrentDomain.BaseDirectory+"\\test.chm", HelpNavigator.Topic, "Welcome.htm");

Welcome is id of the welcome age in chm file

Upvotes: 1

abhilash
abhilash

Reputation: 5641

You can use -

System.Windows.Forms.Help.ShowHelp(Control, String)

So assuming you are in a Form/Control

Help.ShowHelp(this, "file://c:\\helpfiles\\help.chm");

ShowHelp method also provides overloads to go to specific topic and help page located inside the compiled HTML help file.

Read System.Windows.Forms.Help.ShowHelp on MSDN

Decompiling a CHM file

Is as easy as executing below command in the command prompt.

hh.exe -decompile <target-folder-for-decompiled-content> <source-chm-file>

For Example:

hh.exe -decompile C:\foo\helpchmextracted help.chm

After executing the above command you should find the decompiled content in the C:\foo\helpchmextracted folder.

Upvotes: 27

Nasuh Levent YILDIZ
Nasuh Levent YILDIZ

Reputation: 141

        string helpFileName = @"c:\help.chm";
        if (System.IO.File.Exists(helpFileName))
        {
            Help.ShowHelp(this, helpFileName );                
        }

if this is not work try

        if (System.IO.File.Exists(helpFileName))
        {
            System.Diagnostics.Process.Start(helpFileName);              
        }

Upvotes: 6

Khirendra Chemjong
Khirendra Chemjong

Reputation: 1

Simple do this

Help.ShowHelp(ParentForm, "chmFile.chm", "link.htm");

Upvotes: 0

fardjad
fardjad

Reputation: 20394

Adding my comments to an answer as per request:

It seems that the file name in the first statement is not correct however the second one should work unless the file is locked, not exists or you don't have permissions to access the file. If you want to ShellExecute the file then you should use System.Diagnostics.Process class, but if you want to extract the contents of the CHM, since is compiled and formatted, it can't be read like plain text files. Take a look at these links:

Decompiling CHM (help) files with C#

CHM Help File Extractor

Upvotes: 2

MBen
MBen

Reputation: 3996

Well the second line should be ok, if the file is not existent it should throw an exception. Need to be more specific about what you mean by " it doesn't work"

Upvotes: 1

Related Questions