How to replace one line in txt file with another line

How to replace one line in txt file with another line with some search criteria

What is that criteria?

Well to do search for a particular line and then you wanna replace with another then you can use
String.Replace(“text to find”,“text to be replace”).
Steps :slight_smile:

  1. Use Read text file activity to read your text file it will return all your text file data in the form of string.Store that data into your output defined variable(Suppose variable name is Str_Data here) for this activity.
  2. Now use the new variable to store new data and apply the String.Replace() on the read text file activity output variable.

String New_Data = Str_Data.Replace(“text to find”,"text to be replace);

  1. use write line to debug your new text data and use where you want.

Regards…!!
Aksh

1 Like

Thank you Aksh,
Actually i am trying to replace the user name and password for Wizard macro file by opening it in txt format.
so it contains “Myhost.Keys” string in so many places, at second occurence i have username and password(Myhost.keys(“user namepassword”) that i want to replace with another values if want every time.So could you please suggest me how can i proceed