当前位置:编程学习 > C#/ASP.NET >>

求助 asp.net 实现下载功能,数据库中文件路径为绝度路径,如何实现下载

string filePath = Server.MapPath(myPicture.Paths);//myPicture.Paths是数据库中的路径

            if (System.IO.File.Exists(filePath))
            {
                System.IO.FileInfo file = new System.IO.FileInfo(filePath);
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); 
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));   
                Response.AddHeader("Content-length", file.Length.ToString());
                Response.ContentType = "appliction/octet-stream";
                Response.WriteFile(file.FullName);
                Response.End();



错误   E:\Pictures\Love\1.jpg不是有效的虚拟路径 ASP.NET
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,