2015-12-21 102 views
0

當我雙擊打開我的chm文件時,所有外部鏈接都可以正常工作。但是當我通過winform按鈕單擊事件打開我的chm文件時,exteranl鏈接不起作用。 外部鏈接包括一些pdf文件。我開始chm如下;chm文件外部鏈接在winform上不起作用

pDokumantationCHMFile.StartInfo.FileName = @"C:\Users\Administrator\Desktop\MANUEL\Example.chm"; 
pDokumantasyonCHMFile.Start(); 

這可能是什麼原因?

+0

我不太清楚,但是這是你的代碼示例中一個錯字pDokumantasyonCHMFile.Start()?; => pDokumantationCHMFile.Start(); –

+0

是的,我用這種方式啓動chm – tebdilikiyafet

回答

0

我認爲鏈接文件在本地開發文件夾和生成的版本「\ bin」文件夾中有不同的位置。請確保所有文件(CHM和PDF)具有相同的位置,並且始終在您的應用程序發行文件夾中發佈。

如果這可能不會幫助,請看看以下在討論串中提到的樣本下載: How to open specific topic from a chm file?

我的方式通過的Process.Start做(例如只 - 這是不是最好的方法):

private void button1_Click(object sender, EventArgs e) 
    { 
     string helpFilePath = Application.StartupPath + @"\help-subfolder\C-Sharp-CHM-example.chm"; 
     // Verify if the file exists 
     if (File.Exists(helpFilePath)) 
     { 
      Process.Start(helpFilePath); 
     } 
     else 
     { 
      Console.WriteLine(string.Format("File not found [{0}]", helpFilePath)); 
     } 
    } 

帶有一些測試鏈接的幫助文件位於子文件夾中。任何地方都可以進行測試,我自己創建了一個CHM文件進行測試,並且沒有鏈接到PDF的問題。我的Visual Studio 2015社區位於Windows 10機器上。

enter image description here

我記得的一些32/64位的問題。請參閱以下鏈接並注意您需要HTML鏈接中的target = _blank。

https://helpman.it-authoring.com/viewtopic.php?f=30&t=12508

+0

文件夾放置很重要嗎?因爲我不使用chm作爲幫助。我像任何程序一樣開始。 – tebdilikiyafet

+0

@tebdilikiyafet,請檢查更新後的答案,並提供一些關於在應用程序中創建CHM鏈接和用例的更多信息。 –