怎样把word文档直接显示在浏览器中(用c#语言)!
谢谢!
谢谢!
解决方案 »
- 【200顶着有分,急】WebBrowser控件编辑模式CTRL+Z失效的问题 或 怎样禁止弹出文档已修改对话框?
- (急切求助)C#如何调用"VC++.Net下生成的MFC DLL"?(在线等)
- [攒分贴]每日小知识
- 怎样才能把主程序和引用的dll放于不同目录?
- 怎样根据Schema来验证XML的和法性
- 关于EXCEL的问题,好多天没解决,高手指教!
- 高手请进:如何用 gdi+ 实现 winform 类似任务管理器中的cpu占有率图或者内存使用率图,多谢了,向你致敬
- 将侦听SOCKET放到一个线程中,当关闭线程时,SOCKET不能同时关闭,怎样关闭它呢
- 怎样编写邮件收发系统??急急,谢谢!!!
- 如何保证生成的随机数不重复
- richtextbox内容如何格式保存到文本文件中
- 关于EF继承Model的表关系
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/msword";
string s=Server.MapPath("C#语言参考.doc");
Response.WriteFile("C#语言参考.doc");
Response.Write(s);
Response.Flush();
Response.Close();
第二种方法: Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/msword"; string strFilePath=""; strFilePath =Server.MapPath("C#语言参考.doc");
FileStream fs = new FileStream(strFilePath,FileMode.OpenOrCreate,FileAccess.Read);
Response.WriteFile(strFilePath,0,fs.Length); fs.Close(); 第三种方法:string path=Server.MapPath("C#语言参考.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=文件名.doc"); Response.Flush(); Response.BinaryWrite(filedata); Response.End();
http://ufo-crackerx.blog.163.com/blog/static/11307877820111017113958413/