65.9K
CodeProject is changing. Read more.
Home

HelpButton: A Button Linked to a Topic of a chm Help File

starIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

1.00/5 (1 vote)

Mar 8, 2011

CPOL
viewsIcon

9620

May be this will help instead of writing the path all the time:private void showHelp() { string dirpath = string.Empty; //string filename = "ACHWINAPP.chm"; dirpath = System.Environment.CurrentDirectory; string[] files = new...

May be this will help instead of writing the path all the time:
private void showHelp()
        {
            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);
        }