关于asp.net 打开word文档~~~~~

来源:百度知道 编辑:UC知道 时间:2024/05/23 19:02:02
string path=Server.MapPath("../temp.doc");
FileInfo file=new FileInfo(path);
FileStream myfileStream=new FileStream(path,FileMode.Open,FileAccess.Read);
byte[] filedata=new Byte[file.Length];
myfileStream.Read(filedata,0,(int)(file.Length));
myfileStream.Close();
Response.Clear();
Response.ContentType="application/msword";
Response.AddHeader("Content-Disposition","attachment;filename=Report.doc");
Response.Flush();
Response.BinaryWrite(filedata);
Response.End();

客户端执行以后,出现下载对话框,我想要的效果是直接用word打开
我尝试把Response.AddHeader(.......)这句去掉,可以直接打开,但是word文档嵌在了ie窗口里了,如何解决?谢谢

这样不可能的
要是用网页可以执行本地的应用程序的话
那还得了
那你的电脑里面肯定全是病毒了

我不晓得

不可能的,除非微软出了office 的url挂接控件。
下载对话框本身就有个打开按钮,你按一下,就先下载,再打开了