日期:2014-05-18 浏览次数:20414 次
System.Text.StringBuilder outputBuffer=new System.Text.StringBuilder(); string filename=DateTime.Now.ToString("yyyyMMddhhmmss")+".txt"; outputBuffer.AppendFormat("{0}",savetxt); System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename="+filename); //System.Web.HttpContext.Current.Response.AddHeader("Content-Length", size); System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream"; System.Web.HttpContext.Current.Response.Charset = "UTF-8"; System.Web.HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.UTF8.GetBytes(outputBuffer.ToString())); System.Web.HttpContext.Current.Response.End();