Thursday, August 06, 2009

Make a great PowerPoint presentation

Monday, August 03, 2009

C# ASP.NET use StringBuilder to export a txt file


StringBuilder strAAA = new StringBuilder();
foreach (DataRow drABC in datatableDEF.Rows)
{
strAAA.Append(drABC["xxxxx"]);
strAAA.Append(drABC[" "]);
strAAA.Append(drDEF["yyyyy"]);
strAAA.Append(drABC[" "]);
strAAA.Append(drGHI["zzzzzz"]);
strAAA.Append(drABC[" "]);
}

//end current line and start a new line
strAAA.AppendLine();
Response.AddHeader("content-disposition", "attachment;filename=ABC.txt"); Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.text"; StringWriter stringWrite = new StringWriter(); HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); Response.Write(strAAA.ToString()); Response.End();