string AllText = System.IO.File.ReadAllText(@"c:\temp.txt");
StringBuilder str = new StringBuilder(AllText);
str.Replace("Old Values","New Values");
this.WriteToFile(@"c:\temp.txt",str.ToString());
private bool WriteToFile(string path, string content)
{
if (!string.IsNullOrEmpty(path))
{
try
{
using (StreamWriter sw = new StreamWriter(path))
{
sw.WriteLine(content);
}
return true;
}
catch (Exception ex)
{
MessageBox.Show("Cant write in file...\n" + ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
}
return false;
}