How to change value in a text file?

I want to dynamically change the value in a robotstream.config file . I want to dynamicall replace the port value. Thanks.

<aa key="port" value="433" />


Can you try the following? (case for change to 8443)

yourString = System.Text.RegularExpressions.Regex.Replace(str,"(?<=\<aa\s+key=""port""\s+value="")\d+(?=""\s+/\>)|(?<=\<aa\s+value="")\d+(?=""\s+key=""port""\s*/\>)","8443")

However if it’s xml, it might be better to use Deserialize XML activity than string manipulation.


You file is a xml right?

You can use Deserialize XML activity, manipulate any node/value that you need and save it.

This activity returns a XDocument, you can read more how to use it here: XDocument Class (System.Xml.Linq) | Microsoft Docs

If you need help in the solution please share you config file replacing any sensitive data.