我正在尝试在C#中打开帮助文件(chm扩展名)。
File.Open(@"//help.chm",FileMode.Open, FileAccess.Read, FileShare.Read);
和
FileStream fileStream = new FileStream(@"c:\help.chm", FileMode.Open);
不起作用 :(
我正在尝试在C#中打开帮助文件(chm扩展名)。
File.Open(@"//help.chm",FileMode.Open, FileAccess.Read, FileShare.Read);
和
FileStream fileStream = new FileStream(@"c:\help.chm", FileMode.Open);
不起作用 :(
System.Windows.Forms.Help.ShowHelp(Control, String)
假设你正在一个表单/控件中
Help.ShowHelp(this, "file://c:\\helpfiles\\help.chm");
ShowHelp
方法还提供了重载函数,可以转到编译的HTML帮助文件中特定主题和帮助页面。
在MSDN上阅读System.Windows.Forms.Help.ShowHelp
反编译CHM文件
只需在命令提示符中执行以下命令即可。
hh.exe -decompile <target-folder-for-decompiled-content> <source-chm-file>
例如:
hh.exe -decompile C:\foo\helpchmextracted help.chm
执行上述命令后,您应该在C:\foo\helpchmextracted
文件夹中找到反编译内容。 string helpFileName = @"c:\help.chm";
if (System.IO.File.Exists(helpFileName))
{
Help.ShowHelp(this, helpFileName );
}
如果这不起作用,请尝试
if (System.IO.File.Exists(helpFileName))
{
System.Diagnostics.Process.Start(helpFileName);
}
System.Diagnostics.Process
类,但是如果您想要提取 CHM 的内容,因为它是编译和格式化的,所以不能像普通文本文件那样读取。请参阅以下链接:
使用 C# 反编译 CHM (帮助) 文件
CHM 帮助文件提取器
好的,第二行应该没问题,如果文件不存在,它应该会抛出一个异常。你需要更具体地说明你所说的“它不起作用”是什么意思。
Help.ShowHelp(this, AppDomain.CurrentDomain.BaseDirectory+"\\test.chm", HelpNavigator.Topic, "Welcome.htm");
System.Diagnostics.Process.Start(@"c:\help.chm");
只需简单地执行此操作
Help.ShowHelp(ParentForm, "chmFile.chm", "link.htm");