如何在不关闭应用程序的情况下获取系统短日期模式 [英] How to fetch system short date pattern without closing the application
问题描述
目前,我可以从此区域性信息中获取ShortDatePattern
CultureInfo cultureInfo = CultureInfo.CurrentCulture;
字符串datePattern = cultureInfo.DateTimeFormat.ShortDatePatter
但是如果我从PC更改短日期格式,该模式将不会更改,直到因为CultureInfo再次调用了apllication -启动后它仍将保留在应用程序中.是否有另一种方法可以从系统中获取ShortDatePattern而不使用CultureInfo
Currently i can fetch ShortDatePattern form this culture info
CultureInfo cultureInfo = CultureInfo.CurrentCulture;
string datePattern = cultureInfo.DateTimeFormat.ShortDatePatter
But if i change short date format from PC this pattern will not change untill apllication is invoked again because of CultureInfo-This will remain in application once it is started .Is there another way to fetch ShortDatePattern from system without using CultureInfo
推荐答案
调用 CultureInfo.ClearCachedData [^ ].希望是有帮助的:-)
也许使用 UserPreferenceChangedEventHandler [ UserPreferenceChangedEventArgs.Category属性 [
Call CultureInfo.ClearCachedData[^]. Hope is helps :-)
And perhaps use UserPreferenceChangedEventHandler[^] and check UserPreferenceChangedEventArgs.Category Property[^] to check for Locale - Indicates changes in user preferences for regional settings, such as the character encoding and culture strings.
这篇关于如何在不关闭应用程序的情况下获取系统短日期模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!