I have an application that runs in any one OS (either win7(x86) or win xp).
My project is designed in Visual studio 2010, I am using .Net 4.0.
Earlier the project’s “working directory” in the properties was specified for win 7 but when i build my project it said unable to locate the working directory(C:\Program Files(x86)\app)
I now changed my working to directory as C:\Program Files\app. My application acts as a plugin to MS excel 2003. And now i am able to run it.
so how can i make my application run in both win xp and win 7?
I am using WinForms .net 4.0 c#.
private void MyMenuItem_Click(object sender, EventArgs e)
{
MyMenuItem.Enabled = false;
string installPath;
string helpFileName;
string appName;
installPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
appName = "\\MyApp\\";
if (System.IO.File.Exists(installPath + appName+ helpFileName))
{
System.Windows.Forms.Help.ShowHelp(new System.Windows.Forms.Control() installPath + appName + helpFileName,
System.Windows.Forms.HelpNavigator.TableOfContents);
}
}
Have a look at the Environment.SpecialFolder enumeration
In System.IO there’s a static class called Path with some very nice stuff on
Struggled a bit because I can’t see where you are getting helpFileName from…
One of the things Path.Combine does for you is you don’t have to worry about the backslashes. If there’s a trailing one on an argument it uses it, if there isn’t it pops it in. Hides a lot of mess that, on occasion.