Can be done in one line:
File.WriteAllText("Path", Regex.Replace(File.ReadAllText("Path"), "[Pattern]", "Replacement"));
More Related Contents:
- Easiest way to read from and write to files
- Best way to resolve file path too long exception
- Encode a FileStream to base64 with c#
- How can I check if a string contains two other strings [closed]
- How do I get two numbers between two words (C#) [closed]
- replace string by index of this string [closed]
- Is string check returns false
- Using non-literal strings in different methods in C#
- Case insensitive ‘Contains(string)’
- Calling a function from a string in C#
- Best way to specify whitespace in a String.Split operation
- Accessing Password Protected Network Drives in Windows in C#?
- Creating a comma separated list from IList or IEnumerable
- Replace multiple characters in a C# string
- How can I format a number into a string with leading zeros?
- C# – Get a list of files excluding those that are hidden
- Is string in array?
- Converting from hex to string
- How to get the last five characters of a string using Substring() in C#?
- Remove text in-between delimiters in a string (using a regex?)
- Is there an equivalent to the Scanner class in C# for strings?
- How does StringBuilder work internally in C#?
- Can I simply ‘read’ a file that is in use?
- Writing file to web server – ASP.NET
- ReadAllLines for a Stream object?
- Convert string to hex-string in C#
- Obtain SHA-256 string of a string
- Remove file extension from a file name string
- Does StringBuilder use more memory than String concatenation?
- Operator ‘==’ cannot be applied to operands of type ‘char’ and ‘string’