方法一: HttpResponse resp = System.Web.HttpContext.Current.Response; resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); resp.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlPathEncode(FileName)); resp.Write(sb.ToString()); 方法二: Console.WriteLine(sb.ToString()); FileStream aFile = new FileStream("D:\\temp\\lintest.dat", FileMode.OpenOrCreate); StreamWriter sw = new StreamWriter(aFile); sw.Write(sb.ToString()); sw.Close(); 方法三: Response.Clear(); Response.Buffer = true; Response.ContentType = "text/richtext"; Response.AddHeader("content-disposition", "attachment; filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8) + ";size=0"); Response.Write(sb.ToString()); Response.Flush(); Response.End();
我目前的做法就是一个a标签,链接地址是服务器上的ftp地址,可以实现简单的访问下载功能
|