Jon Cage
Jon Cage

Reputation: 37500

How can I clear cached timezone information in .net 2.0?

I have a sealed Windows XP embedded device which always boots up with the same windows settings. When my software starts up it needs to set the timezone of the machine to a user-configurable setting. Unfortunately, I've discovered that even though I'm updating the timezone, all of the methods in .net which retrieve the system time don't appear to pick up the changes.

A bit of digging suggests that in .net 3.5 and 4.0 there is a method to clear a cache: system.timezoneinfo.clearcacheddata(). I'm working with .net 2.0 though so how can I get around this in .net 2.0?

Is the only option to have a second piece of software running to set the timezone before the main application runs (re-loading the software appears to fix the issue)?

Upvotes: 1

Views: 944

Answers (1)

Jon Cage
Jon Cage

Reputation: 37500

Nevermind; I found a solution that works all the way back to .net v1.0:

System.Globalization.CultureInfo.CurrentCulture.ClearCachedData();

Upvotes: 4

Related Questions