该Environment.CurrentDirectory属性将被设置为您的.exe文件的位置.因此,如果您将帮助文件夹放在那里,它将是:
// The path to the Help folder.
string directory = Path.Combine(Environment.CurrentDirectory, "Help");
// The path to the Help file.
string filePath = Path.Combine(directory , "myHelpFile.chm");
// Launch the Help file.
Process.Start(filePath);
Run Code Online (Sandbox Code Playgroud)
编辑:我应该说,这Environment.CurrentDirectory指向默认情况下在Windows窗体应用程序中启动进程的文件夹,但其值可以通过某些控件(如OpenFileDialog- 请参阅此处的解决方法)在应用程序的生命周期中更改.在Windows服务下,Environment.CurrentDirectory映射到%SystemDirectory%.
您应该使用Help.ShowHelp来执行此操作
var chmFile = "CHM/test.chm";
Help.ShowHelp(ctrl, chmFile);
Run Code Online (Sandbox Code Playgroud)
默认情况下,ShowHelp将在应用程序路径中搜索文件