tags:

views:

63

answers:

1

Hi,

we have the problem that ShowHelp seems to fail under Vista and Windows Server 2008 if the path name of the help file contains a virtualized folder name. For example, under the German version Vista, "Program Files" is called "Programme". The call

System.Windows.Forms.Help.ShowHelp(null, 
   @"C:\Programme\Microsoft Visual Studio 9.0\Common7\Tools\spyxx.chm");

fails, wheras

System.Windows.Forms.Help.ShowHelp(null,
   @"C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\spyxx.chm");

succeeds.

If there any way in C# to convert a file path into its non-virtualized counterpart?

Or is there any other solution to that problem?

Regards

A: 

It fails because C:\Programme isn't the real folder - it's just a displayed name. On Vista and 7, these folders ALWAYS have English names, regardless of OS language.

The right way is to look in the registry and see where it's installed. Look in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0 for the InstallDir key. This will be something like c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ if you have - tou can then manipulate this path to get to Common7\Tools instead.

In other words, simply don't hardcode the path.

If you must know the name of the Program Files folder, use GetFolderPath with the appropriate parameter instead of hardcoding it.

Michael Madsen
The "Visual Studio" path name above actually was only an example, to show that the problem is not a bug in our help files. Our program is installation-free (i.e. you just copy it into the target folder). Therefore, we cannot use the registry to determine the installation location. We have to rely on Assembly.Location or similar methods to get the installation location; these methods always return "Programme" instead of "Program Files".
fmunkert
@fmunkert: I cannot reproduce that behavior. Creating a test app and printing Assembly.GetExecutingAssembly().Location gives me the English name, not the localized name shown in Explorer - which it *should*, because you're supposed to use the Windows API when you want to show the localized name instead of the real name.
Michael Madsen