Click here to Skip to main content
15,887,683 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
1.00/5 (1 vote)
8 Mar 2011CPOL 9K   2   3
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:

C#
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);
        }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
I am working as a Software engineer. Web development in Asp.Net with C#, WinForms and MS sql server are the experience tools that I have had for the past 3 years. Yet to work on WCF, WPF, Silverlight and other latest ones.

Comments and Discussions

 
GeneralWhat ever file name it is he has to give the name there i ju... Pin
demouser74313-Mar-11 23:05
demouser74313-Mar-11 23:05 
GeneralReason for my vote of 1 Explained in my comments. Pin
Olivier Levrey8-Mar-11 1:48
Olivier Levrey8-Mar-11 1:48 
General1- Using <CODE>CurrentDirectory</code> is not recommanded si... Pin
Olivier Levrey8-Mar-11 1:47
Olivier Levrey8-Mar-11 1:47 
1- Using CurrentDirectory is not recommanded since it may change after any FileDialog is used. 2- You are making assumption on the help file name: why would everybody use ACHWINAPP.chm as the name for their help file??? 3- I don't understand why you want to get rid of the file path property...

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.