[英]How can I check if configuration file is proper?
有什么方法可以在.net中检查我的配置文件(我提供自己的配置)是否正确,而无需根据Xml Schema对其进行验证?
Have a look in the System.Configuration namespace. 看一下System.Configuration命名空间。 There is a class for reading the config settings which does this for you without great effort. 有一个用于读取配置设置的类,可以轻松完成此操作。
I'm fairly sure that the AppSettingsReader class will give you some good validation techniques. 我相当确定AppSettingsReader类将为您提供一些良好的验证技术。 I usually just use the boilerplate code provided by the app settings in visual studio to do this though, if the file is invalid then the system will fall back onto defaults. 我通常只使用Visual Studio中应用程序设置提供的样板代码来执行此操作,如果文件无效,则系统将恢复为默认值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.