You cannot apply HTML format in a txt file. But if you only want to save the html there you can...
Just from
here[
^].
StreamWriter objReader = null;
try
{
string encoded = HttpContext.Current.Server.HtmlEncode(st);
objReader = new StreamWriter(@"F:\Richa222.txt");
objReader.Write(encoded);
}
catch
{
}
finally
{
objReader.Close();
}
Hope it helps.