110,561
社区成员
发帖
与我相关
我的任务
分享
HttpWebRequest hr = (HttpWebRequest)HttpWebRequest.Create(@"http://localhost/test/Error1.htm"); //你请求的地址
hr.KeepAlive = false;
HttpWebResponse hr2 = (HttpWebResponse)hr.GetResponse();
StreamReader sr = new StreamReader(hr2.GetResponseStream(), Encoding.Default);
string str = "";
while (sr.Peek() != -1)
str += sr.ReadLine();
Response.ContentEncoding = System.Text.Encoding.Default;
StringWriter word = new System.IO.StringWriter();
Response.AppendHeader("Content-Disposition", "attachment;filename=FileName.doc"); //保存的文件名
Response.ContentType = "application/vnd.ms-word";
Response.Write(str);