using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
namespace c1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
WebClient client = new WebClient();
//判断图片是否存在
if (!File.Exists("baidu.gif"))
{
//下载图片
client.DownloadFile("http://www.baidu.com/img/baidu_sylogo1.gif","baidu.gif");
}
Image gif = Image.FromFile("baidu.gif");
//新建pictureBox 对象
PictureBox picImage = new PictureBox();
picImage.Location = new Point(50,50); //指定位置
picImage.Height = gif.Height;
picImage.Width = gif.Width;
picImage.Image = Image.FromFile("baidu.gif");
//窗体添加PictureBox 控件
this.Controls.Add(picImage);
}
}
}