如何在不关闭应用程序的情况下获取系统短日期模式

编程入门 行业动态 更新时间:2024-10-25 20:27:05
本文介绍了如何在不关闭应用程序的情况下获取系统短日期模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

更多推荐

如何在不关闭应用程序的情况下获取系统短日期模式

本文发布于:2023-11-25 12:26:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629745.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   情况下   日期   模式   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!