C# pictureBox.Image獲得圖片的三種方法

 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());

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章