目前,我可以从此区域性信息中获取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.
更多推荐
如何在不关闭应用程序的情况下获取系统短日期模式
发布评论