views:

22

answers:

1

Hi,

I've developed a Java application using Eclipse. The OS of the computer I used is Win Vista. I'm having trouble when using this application on a Win XP computer. The problem I've detected is:

If in my code I use the following lines:

File source = new File(C:\\Program Files\\);
boolean directory = source.isDirectory();

The value of the variable directory will be set to true in Win Visto and to false in Win XP. In order to get this variable set to true when using Windows XP I need to use the following lines:

File source = new File(C:\\Archivos de Programa\\); (spanish)
boolean directory = source.isDirectory();

However, with these lines the variable will be set to false in Win Vista.

It looks like Win Vista only 'understands' english and Win XP only 'understands' spanish.

Is there any way of solving this problem or do I have to check in my code which option is valid and, depending on that, use one language or the other?

Thanks.

+1  A: 

You can get the appropriate directory from the ProgramFiles environment variable.

File source = new File (System.getenv("ProgramFiles"));
boolean directory = source.isDirectory();
R. Bemrose