大部分平台通常可以使用:
PictureBox的image属性
代码如下: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());
PictureBox的ImageLocation属性
this.pictureBox2.ImageLocation =D:\\001.jpg;
对于wince平台,没有Image.FromFile,也没有ImageLocation,可通过下列方式
Bitmap MyImage = new Bitmap(D:\\001.jpg );
this.pictureBox2.Image= (Image)MyImage;
则可实现对某个路径上图片的引用