首页 > 代码库 > 下载Word文档
下载Word文档
//方法一 下载word Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "Application/msword"; string s = Server.MapPath(WordPath); Response.WriteFile(WordPath); //Response.Write(s); Response.Flush(); Response.Close(); //方法二 下载word Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "Application/msword"; string strFilePath = ""; //strFilePath = Server.MapPath(WordPath); //strFilePath = "\\\\172.8.8.8\\TEST.doc"; strFilePath = WordPath; FileStream fs = new FileStream(strFilePath, FileMode.OpenOrCreate, FileAccess.Read); Response.WriteFile(strFilePath, 0, fs.Length); fs.Close(); //方法三 下载word string path = Server.MapPath("//172.8.8.8/TEST.doc"); path = WordPath; FileInfo file = new FileInfo(path); FileStream myfileStream = new FileStream(path, FileMode.Open, FileAccess.Read); byte[] filedata = http://www.mamicode.com/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=file.doc"); Response.Flush(); Response.BinaryWrite(filedata); Response.End();
下载Word文档
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。