如何使用位于c:drive中的c#打开,编辑和保存.config文件 [英] how open,edit and save a .config file using c# which is located in c:drive
本文介绍了如何使用位于c:drive中的c#打开,编辑和保存.config文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
类似这样的配置文件中的代码我想将时间值更新为当前小时并保存相同的.请帮助我..首先我必须从文件中搜索renewalservice并将激活时间更新为当前时间...我现在想起来很清楚
the code in config file something like this i want to upadate time value to cuurent hour and save the same .please help me ..first i have to search renewalservice from the file and update activation time to current time...i think now its pretty clear
<provider name="RenewalService" type="Wildnet.WildCommercial.Controller.Renewal.RenewalServices.RenewalService, Wildnet.WildCommercial.Controller">
<providerProperties>
<providerProperty name="Enabled" value="true" />
<providerProperty name="Interval" value="60" />
<providerProperty name="StoredProcedureName" value="uspGetExpiredPolicyIds" />
<providerProperty name="ActivationTime" value="6" />
</providerProperties>
</provider>
推荐答案
编辑web.config文件?
是的,毕竟web.config只是一个文本文件
可行吗?
不,这不是一个好主意,要意识到对web.config所做的任何更改都将导致应用程序在Web服务器上重新启动.这意味着所有会议都告别.不必在web.config中存储这样的动态数据的最佳方法是在数据库中,或者是您可以在运行时解析的xml配置文件中,而不会中断事物的流程.
如果要创建这样的内容,则可能会创建自己的类来实际存储数据.可以使用 XmlSerializer 将该类序列化/反序列化为XML.课.
这些链接肯定会帮助您.
使用.NET 2.0读取/写入App.Config文件 [ ^ ]
http://stackoverflow.com/questions/980440/update-app- config-system-net-setting-at-runtime [ ^ ]
Edit the web.config file?
Yes it''s possible, after all web.config is just a text file
Is it feasible?
No, it''s not a good idea, realize that any change you make to web.config will result in the application being restarted on your webserver. This means all the sessions go bye-bye. The best way to store dynamic data like this that doesn''t have to be in web.config is in a database, or a xml config file you can parse at runtime, without interrupting the flow of things.
If I were going to create something like this, I''d probably create my own class to actually store the data. This class would be able to be serialized/deserialized into XML using the XmlSerializer class.
These links will definitely help you out.
Read/Write App.Config File with .NET 2.0[^]
http://stackoverflow.com/questions/980440/update-app-config-system-net-setting-at-runtime[^]
这篇关于如何使用位于c:drive中的c#打开,编辑和保存.config文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文