请问在.net中,如何下载网页上面的图片文件到本地?

解决方案 »

  1.   

    System.IO.FileInfo file = new System.IO.FileInfo(path);
            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();
      

  2.   

    您好!
    当System.IO.FileInfo file = new System.IO.FileInfo(path);加载文件的时候,不支持url格式,例如http://ad4.sina.com.cn/200607/06/60577_750-450.jpg
      

  3.   

    你想下自己网站的图片还是别人网站的图片
    自己网站的图片可以用上面的方法,把url格式转化成本机路径用Server.MapPath
    别人网站的图片我不会下
      

  4.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=CDBAB4E8-0938-4134-B86F-3B9E2C396E8D
      

  5.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=4AE836F8-CCB4-4BEF-90B1-25BB1A5E6433
      

  6.   

    我正是要通过代理服务器上网,所以webclient方法总是出错