开发者

How can i make my Help file(CHM) to be installed in the Folder where the user install my application

I create a CHM file where user can have that when he click on F1. But what i need is how can i make that to be installed in the folder where the user install my application in such a way that when he click F1 i have to read that from the folder he installed and show it. And also how can i开发者_StackOverflow中文版 call in my application with out calling some thing as c:\sample.chm or some thing i need to call it from the directory where it was


To install the help file, you'll have to add it to your setup project so that it installs in the directory with your executable file.

Once you know the help file will be in your executable directory, you can drop a HelpProvider onto your form. This will connect your help file to the F1 button. You will set HelpNamespace to the path of your help file. To dynamically figure out the path of your directory, you can use System.Reflection.Assembly.GetExecutingAssembly().Location to get the path of your executable and then add that to the name of your help file.

     string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
     appPath = System.IO.Path.GetDirectoryName(appPath);
     myHelpProvider.HelpNamespace = System.IO.Path.Combine(appPath, "myHelpFile.chm");


After all i got the solution

  private void frmMain_HelpRequested(object sender, HelpEventArgs hlpevent)
    {
        string dirpath = string.Empty;
        string filename = "ACHWINAPP.chm";
        dirpath=System.Environment.CurrentDirectory;
        string[] files=new string[100];
        do
        {
            if (dirpath ==string.Empty || dirpath == Directory.GetDirectoryRoot(dirpath))
            {
                MessageBox.Show("no helpfile found");
            }
            else
            {
                files=Directory.GetDirectories(dirpath,"ACH");
                if (files.Length>0)
                {
                    //MessageBox.Show(files[0]);
                    string strHlp = string.Empty;
                    strHlp = files[0] + "\\ACHWINAPP.chm";
                    Help.ShowHelp(this, strHlp);
                    break;
                }
                else
                {
                    dirpath = Directory.GetParent(dirpath).ToString();
                }
            }
        } while (true);

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜