XML Configuration
I have got a scenario :
There is a config file which the installer installs and configures the values in the files based on property variables.
Now after installation the User might configure some settings in the config file. And it gets encrypted with few new values in the complete section.
The issue im facing right now is during upgrade. The config file might change (New settings included in the config file) but the installer has to retain the old values in the config file and include in the new file.
Suppose my installed file looks like :
<connectionStrings>
<add name="test" connectionString="test" providerName="test" />
</connectionStrings>
And after installation the user configurations changes the connectionstring and it gets encrypted and it looks like this:
<connectionStrings New_Variable="test">
<EncryptedData>
<CipherData>
<CipherValue>test</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
So I need to update the new web.config file which is modified during next release version with these values.
Any help would be appreciated.
Regards,
MS
Answers (3)
Can you simply concatenate the old file contents onto the end of the new file using copy /y oldfile+newfile and have it work, or do you need to read the file in and parse it line by line looking for where to insert the current values?
Comments:
-
This link might help a little. http://stackoverflow.com/questions/1115508/batch-find-and-edit-lines-in-txt-file - philologist 12 years ago
Where is this config file residing? In AllUsersProfile?
Comments:
-
Nah copying wont help as the file is in xml format.
And the file is installed in program files.... - manitha21 12 years ago -
Did I ask you to copy the xml file? :)
You can read the xml file which is residing in %ProgramFiles% and update your new xml file based on that using VBScript custom action
http://technet.microsoft.com/en-us/magazine/2008.02.heyscriptingguy.aspx?pr=PuzzleAnswer - jagadeish 12 years ago