如何在不关闭应用程序的情况下获取系统短日期模式 [英] How to fetch system short date pattern without closing the application

查看:74
本文介绍了如何在不关闭应用程序的情况下获取系统短日期模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我可以从此区域性信息中获取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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆