Click here to Skip to main content
15,907,329 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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
XML
<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>
Posted
Updated 22-Feb-12 7:02am
v4
Comments
sadashiva swamy 22-Feb-12 1:59am    
the code which is present somewhere in local drive so i heve to open it first and there are around 900 params are there out of which i have to find this and edit it to current time and save it back
Varun Sareen 22-Feb-12 21:26pm    
Please mark it as your answer if it helps you out

1 solution

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[^]
 
Share this answer
 
v2
Comments
sadashiva swamy 22-Feb-12 2:29am    
i think u didnt get my qstn the code which i shown is .config file which doesnot exists in soltnexplorr which is located in c:drive so i wan open the file and edit it and save all these process shud be done in single click
Varun Sareen 22-Feb-12 4:03am    
ohhh!! :(...I have updated the solution. Please see if it helps you out.
sadashiva swamy 23-Feb-12 0:56am    
the thing is i cannt configure the file which i am talking about ..ok
basically i need it to open and edit and then save ..

wat idea u have given is not sufficient ..will you make it more clear

file is:c:\newfoder\service.config

ok

this i have to open and update the activation time as i explained before.

then have to it back to the same folder
Varun Sareen 23-Feb-12 11:54am    
will get back to you soon with some solution to it :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900