c # Picturebox path

 picHeadImg.ImageLocation = string.Format("http://img3.imgtn.bdimg.com/it/u=4160106393,1595591376&fm=214&gp=0.jpg");
 // picHeadImg.Image = Image.FromStream(WebRequest.Create(head_img).GetResponse().GetResponseStream());

  picHeadImg.Image = Properties.Resources.DefulatHeadImg;

picHeadImg.Load (pathname) 


1. absolute path:
this.pictureBox.Image the Image.FromFile = ( "C: \\ test.jpg");
 
2. the relative path:
Application.StartupPath;  
get root directory  
this.pictureBox. Image = Image.FromFile (Application.StartupPath "\\ test.jpg ");
 
path 3. Access to the network picture
 
string url = "http://img.zcool.cn/community/01635d571ed29832f875a3994c7836.png@900w_1l_2o_100sh.jpg";
= Image.FromStream this.pictureBox.Image (System.Net.WebRequest.Create (URL) .GetResponse () the GetResponseStream ().);


// save
 SaveFileDialog save = new SaveFileDialog();
save.ShowDialog();
if (save.FileName != string.Empty)
 {
   picHeadImg.Image.Save(save.FileName);
 }  



 // asynchronous load image, the image loaded txtURI
 pictureBox1.LoadAsync (txtURI.Text); 



Private void pictureBox1_LoadProgressChanged (Object SENDER, ProgressChangedEventArgs E)
        {
            // display progress
            this.lblMsg.Text = string.Format ( "Current Progress: {0 } ", e.ProgressPercentage);.
        }

        Private void pictureBox1_LoadCompleted (Object SENDER, AsyncCompletedEventArgs E)
        {
            // event handling load error
            IF (e.Error = null)!
            {
                lblMsg.Text =" error message: "+ e.Error .Message;
                return;
            }
            // If canceled
            IF (e.Cancelled)
            {
                lblMsg.Text = "operation was canceled.";
            }
            the else
            {
                lblMsg.Text = "loaded.";
            }
            button1.Enabled = to true;
        }

Guess you like

Origin www.cnblogs.com/ruiyuan/p/11445739.html