I wanted to replace a certain string (an adsense id) in thousands of files, so I thought doing it in vb.net. This is not a question, I found the solution. This is just some code that does the replacing for people that want to put it in future projects I assume you have a textbox named "adsense_txt.Text" that contains the target adsense id Also I assume that you have assigned to the variable "copiedmiscfile2" the path to the file you want the replacing to be done. You just need to loop through all your files this code that will read the file line by line until it finds a match and replace it 'replace target adsense with the curent adsense pub-xxxxxxxxx Dim rx5 As New Regex("pub-tobereplaced", RegexOptions.IgnoreCase) Dim filename5 As String = copiedmiscfile2 Dim sr5 As New StreamReader(filename5) Dim source5() As String = sr5.ReadToEnd.Replace(Environment.NewLine, Chr(13)).Split(Chr(13).ToString.ToCharArray) sr5.Close() Dim Changes5 As New List(Of Integer) For a As Integer = 0 To source5.Length - 1 If rx5.IsMatch(source5(a)) Then source5(a) = rx5.Replace(source5(a), adsense_txt.Text) Changes5.Add(a + 1) End If Next Dim sw5 As New StreamWriter(filename5) sw5.Write(String.Join(Environment.NewLine, source5)) sw5.Close() Code (markup):