zl程序教程

您现在的位置是:首页 >  后端

当前栏目

C# pictureBox.Image获得图片的三种方法

c#方法 图片 三种 获得 Image
2023-09-14 09:11:18 时间
 1 1.绝对路径: 
 2 this.pictureBox.Image=Image.FromFile("C:\\test.jpg"); 
 3  
 4 2.相对路径: 
 5 Application.StartupPath;  
 6 可以得到程序根目录  
 7 this.pictureBox.Image=Image.FromFile(Application.StartupPath "\\test.jpg"); 
 8  
 9 3.获得网络图片的路径 
10 string url="http://img.zcool.cn/community/01635d571ed29832f875a3994c7836.png@900w_1l_2o_100sh.jpg";
11 this.pictureBox.Image= Image.FromStream(System.Net.WebRequest.Create(url).GetResponse().GetResponseStream());