可以参考这段代码.里面的ContentType告诉浏览器下载的内容是个word文档,可以用word打开.其它文档类型的可以从这里找到: http://www.w3schools.com/media/media_mimeref.asp .
byte[] fileContent = ...
string filename="file1.doc";
Response.ClearHeaders();
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename="+filename);
Response.ContentType = "application/msword";
Response.Write(fileContent);
Response.Flush();
Response.End();
如果遇到 IE 对文件名处理出错,里边有出现了"[1]"这样的bug,可以看一下这里:
http://www.cnblogs.com/deerchao/archive/2007/10/14/924018.html