请问在.net中,如何下载网页上面的图片文件到本地?
解决方案 »
- 【在线等】XmlSerializer Format问题
- 计算两个动态时间段的倒计时问题
- Jmail问题,求高人指点!!
- 用Remoting做C/S程序,Client端如何获取网络的通断情况?
- 請問如何對datagrid中資料改變顏色?
- 关于CheckBox的选中问题
- 对于DataSet中的数据的表格式输出问题??高手请进。。顶者有分..
- 如果快速得到一个软件的安装目录?
- 可以获取其他程序的datatable吗。
- 客户端发现响应内容类型为“text/html; charset=utf-8”,但应为“text/xml”。
- 关于media player 播放器的问题???/
- WEB打印疑问,急!!请高手帮忙解决!!感谢!!
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(file.Name)); Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
当System.IO.FileInfo file = new System.IO.FileInfo(path);加载文件的时候,不支持url格式,例如http://ad4.sina.com.cn/200607/06/60577_750-450.jpg
自己网站的图片可以用上面的方法,把url格式转化成本机路径用Server.MapPath
别人网站的图片我不会下