This seems to have happened completely randomly. One minute the program was working, then I made some changes (completely unrelated to this part of the program, all I actually changed was one of the embedded resources of the project) and the following property now returns just a "\"
.
public static string ProgramDataDir
{
//this has always worked on all windows OSes before, but all of a sudden, not so
//get { return Environment.GetEnvironmentVariable("ProgramData") + @"\"; }
//I've tried changing it to this, and this doesn't work either - same results
get { return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\"; }
}
This property should, and has always returned C:\Documents and Settings\All Users\Application Data
on XP and Server 2003. This no longer works on a virtual 2003 machine and a virtual XP machine, both running on the same virtual host. The host doesn't have any effect on these environment variables does it? Could it be a problem with my virtual host? Unfortunately I don't have an available, standalone Server 2003 or XP machine that I can install this software and run tests on.
Note: I realise that this part is not a programming question as such, more a server issue, but due to the nature of the rest of the question I feel it still suited SO, please correct me if I'm wrong.
Also, I haven't touched this project in some time, I'm pretty sure I haven't changed any settings except for the assembly version number, but I don't know and can't remember if I had changed any of the compilation settings or similar after the last working version. Would any of these kind of settings have this sort of effect on my application?
The application is running as a Windows Service, so using any of the user special folders isn't appropriate for this application.