c# pictureBox1.Image的获得图片路径的三种方法 winform

来源:互联网 发布:python timer执行一次 编辑:程序博客网 时间:2024/06/03 05:32

代码如下:c# pictureBox1.Image的获得图片路径的三种方法 winform

1.绝对路径:
this.pictureBox2.Image=Image.FromFile("D:\\001.jpg");

2.相对路径:
Application.StartupPath;
可以得到程序根目录
string picPath=Application.StartupPath+"\\1.gif";

3.获得网络图片的路径

this.pictureBox2.Image= Image.FromStream(System.Net.WebRequest.Create(http://www.xyhhxx.com/images/logo/logo.gif).GetResponse().GetResponseStream());