最近在做一个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());
本文介绍了使用C#实现图片预览的方法,包括从本地文件系统加载图片到PictureBox控件中,无论是通过绝对路径还是相对路径,同时也展示了如何从网络URL获取图片并显示。
1024





