最近在做一个c#图片预览,整理了读取图片给picturebox
1.绝对路径:
this.pictureBox.Image=Image.FromFile("C:\\test.jpg");
2.相对路径:
Application.StartupPath;
可以得到程序根目录
this.pictureBox.Image=Image.FromFile(Application.StartupPath "\\test.jpg");
3.获得网络图片的路径
string url="http://img.zcool.cn/community/01635d571ed29832f875a3994c7836.png@900w_1l_2o_100sh.jpg";
this.pictureBox.Image= Image.FromStream(System.Net.WebRequest.Create(url).GetResponse().GetResponseStream());