[英]How to display chm file in c# winforms application
你需要 :
String exeDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
因此:
String HelpFilepath = "file://" + Path.Combine(exeDirectory , "somehting.chm");
Help.ShowHelp(this, path);
正如我所看到的,從您的問題中調用Help.ShowHelp
的第一個代碼片段還不錯。 有時我使用下面的相關代碼。 可能有許多解決方案...請注意,打字錯誤(例如somehting.chm)會干擾代碼段。
private const string sHTMLHelpFileName = "CHM-example.chm";
...
private void button1_Click(object sender, EventArgs e) {
System.Windows.Forms.Help.ShowHelp(this, Application.StartupPath + @"\" + sHTMLHelpFileName);
}
因此,請打開Visual Studio-解決方案資源管理器並檢查CHM文件的屬性。 轉到下面快照中顯示的下拉框,然后設置“始終復制”(此處僅德語)。 在Debug
模式下啟動項目,然后檢查bin / debug輸出文件夾。 對Release
模式和輸出文件夾執行相同的操作。 CHM應該駐留在這里,希望您的CHM通話成功。
類似主題的答案是:
// get full path to your startup EXE
string exeFile = (new System.Uri(Assembly.GetEntryAssembly().CodeBase)).AbsolutePath;
// get directory of your EXE file
string exeDir = Path.GetDirectoryName(exeFile);
// and open Help
System.Windows.Forms.Help.ShowHelp(this, exeDir+"\\"+"somehting.chm");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.