Click here to Skip to main content
15,886,753 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I placed my help file in my application folder. For example i created my application namely ACH in D drive such that my help file will be in this location


D:\ACH\Help.chm

I would like to open this when the user press F1 on my form. How can i get this with out writing the path directly.

I would like to get the path D:\ACH any idea

The actual is if i create an MSI for my application and give it to user he can install anywhere so that when he runs the application and clicks on F1 for help i would like to open the chm file that was in the installed folder
Posted
Updated 5-Dec-10 21:35pm
v2
Comments
sandipapatel 6-Dec-10 4:01am    
No need to worry.
Add the .chm file in u r project folder and then publish the application/create setup.
Now,suppose u have added that file in a folder called "Help" so, use
String strPath = "~/Help/Filename.chm";
....
So, simple man. Try it. Because it will be so easy and manageable in future also.
demouser743 6-Dec-10 4:05am    
If i am not adding any directory means
demouser743 6-Dec-10 4:06am    
How can i test it while i am running it through program
demouser743 6-Dec-10 4:13am    
This doesn't work for me

1 solution

Try this

string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
 
Share this answer
 
Comments
demouser743 6-Dec-10 3:38am    
This gives the Path for Debug folder na
qontary 6-Dec-10 4:16am    
It will return Debug folder because your executable is inside that folder.
demouser743 6-Dec-10 4:24am    
But i need the exact folder suppose i give you my MSI file to you you can install in c: directly so that my files will be placed in c as follows
c:\ACH\help.chm along with dll's and other or you can directly install in the default path as c:\programfiles\ACH\ i need to get the correct path
qontary 6-Dec-10 5:09am    
I think you misunderstand how the code above works. The code will return your executable location. If you copy your executable to another location, the path value will change accordingly. I think the code will suit your requirement with a little modification.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900