Write Data into a Text File

Lakhangarg
Posted by Lakhangarg under C# category on | Views : 2121
private void GenerateTextFile()
{
string strHTMLContent = "My Name is Lakhan Pal Garg. \r\n I am a Senior Software Engineer. \r\n And i am Working in a Product Based Company.";
string attach = "attachment; filename=Lakhangarg.txt";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "";

HttpContext.Current.Response.ContentType = "application/text";
HttpContext.Current.Response.AddHeader("content-disposition", attach);
HttpContext.Current.Response.Write(strHTMLContent);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();
}

Comments or Responses

Login to post response