怎样从一个URL下载图片并保存到本地呢?急~~~~~

cushat 2006-10-27 02:40:56
现在想通过给定的URL (http://image2.sina.com.cn/home/images/sina_logo2.gif)
把图片保存至指定的文件名 (c:\sina.gif)
应该怎么做啊,急~~~~
...全文
525 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
szpublice 2006-10-29
  • 打赏
  • 举报
回复
好贴当顶.
wangchaocn 2006-10-29
  • 打赏
  • 举报
回复
mark
sanniko 2006-10-29
  • 打赏
  • 举报
回复
Codeproject 上有一个Sample.去搜索WebSpider
xiaomatian 2006-10-29
  • 打赏
  • 举报
回复
/*
* Created by SharpDevelop.
* User: Administrator
* Date: 2005-10-24
* Time: 17:21
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Net;
using System.IO;
using System.Text;

namespace webdownload
{
class MainClass
{
public static void Main(string[] args)
{
try
{
Console.WriteLine("Hello World!");
string remoteUri = "http://community.csdn.net/images/";
string fileName = "CSDN_logo.GIF";
string myStringWebResource = null;
WebClient myWebClient = new WebClient();
myStringWebResource = remoteUri + fileName;
myWebClient.DownloadFile(myStringWebResource,fileName);
Console.WriteLine("Downoad OK!");
//web request;
WebRequest request = null;
WebResponse response = null;
request = WebRequest.Create("http://community.csdn.net/images/CSDN_logo.GIF");
//response =request.GetResponse();
StreamReader sr = new StreamReader(request.GetResponseStream()
/*
Stream stream = response.GetResponseStream();
string fname="csdn.gif";
ASCIIEncoding encoder = new ASCIIEncoding();
byte[] byteArray = encoder.GetBytes(fname);
stream.Write(byteArray,0,fname.Length);
stream.Close();
*/
Console.WriteLine("Downoad OK!!");

}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}

以前写了测试测试的。
wsxcy66668888 2006-10-27
  • 打赏
  • 举报
回复
Imports System.Net

Dim mywebclient As New WebClient
mywebclient.DownloadFile("http://image2.sina.com.cn/home/images/sina_logo2.gif", "d:\down\sina_logo2.gif")
Messagebox.show("下载完成","")
wsxcy66668888 2006-10-27
  • 打赏
  • 举报
回复
Dim mywebclient As New WebClient
Dim i As Integer
mywebclient.DownloadFile("http://image2.sina.com.cn/home/images/sina_logo2.gif", "d:\down\sina_logo2.gif")
Messagebox.show("下载完成","")
cushat 2006-10-27
  • 打赏
  • 举报
回复
看不明白啊,有没有System.Net里面的实现方法?
xingyaohua 2006-10-27
  • 打赏
  • 举报
回复
参考一下
http://chinat1.blog.hexun.com/4799820_d.html

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧