简体   繁体   English

如何检查配置文件是否正确?

[英]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.

相关问题 如何检查代码文件的有效性? - How can I check the validity of a code file? 如何为.NET控制台应用程序设置配置文件? - How can I set up a configuration file for .NET console applications? 如何以编程方式更新log4net配置文件? - How can I programmatically update log4net configuration file? 如何使用代码配置而不是XML文件配置启动服务器? - How can I start the server with the code configuration rather than the XML file configuration? 使用选项模式时如何检查缺少的配置部分? - How can I check for a missing configuration section when using the Options pattern? 在哪里可以找到“ SuperWebSocket”(Supersocket)的配置文件? 或者如何在代码中更改websocket的ReceiveBufferSize? - Where can I find the configuration file for “SuperWebSocket” (Supersocket)? Or how can I change ReceiveBufferSize for websocket in code? 如何使用PowerShell检查文件是否超过特定时间? - How can I check if a file is older than a certain time with PowerShell? 如何检查我是否可以在特定文件夹中创建文件 - How to check if I can create a file in a specific folder 如何使用自定义配置部分保存配置文件? - How do I save a configuration file with a custom configuration section? 如何检查WCF配置文件中的两个XML元素在功能上是否等效? - How to check if two XML elements in a WCF configuration file are functionally equivalent?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM