导出txt直接让用户选择下载~

 Response.Clear();
        Response.AddHeader("content-disposition", "attachment;filename=FileName.txt");
        Response.Charset = "gb2312";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
        Response.ContentType = "application/vnd.txt";
        StringBuilder sb = new StringBuilder(Regex.Replace(mobiles, ",", "\r\n"));
        System.IO.StringWriter stringWrite = new System.IO.StringWriter(sb);
        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);           
        Response.Write(stringWrite.ToString());
        Response.End();
posted @ 2010-12-23 11:46  子午  阅读(327)  评论(0编辑  收藏  举报