I have a folder in which images are stored. I need that if the condition is met, the program displays one of these images in the pictureBox form. How can I do this? (c #)

  • pictureBox has a Load method - pass your picture as a parameter to this method and that's it - ghost rider
  • 3
    What you need to do to get banned in all search engines? - nitrocaster
  • what do you mean? - Dikaz

3 answers 3

If the condition is true, then we search for files from the folder (read this ), and load the ones selected in the PictureBox (read this and this )

  • and what method to search to use? - Dikaz
  • The reference to the Directory class has an example of usage. I think you will understand - Chad
  • one
    found this Picturebox.Image = Image.FromFile ("#") - Dikaz
  • oh, another question ... and how to do so to take an image from the resources? - Dikaz
  • We read the last link about bitmaps and see the FromResource method - Chad
  if (/*ваше условие*/) { System.IO.FileStream fs = new System.IO.FileStream(@"Путь к файлу", System.IO.FileMode.Open); System.Drawing.Image img = System.Drawing.Image.FromStream(fs); fs.Close(); pictureBox1.Image = img; } 

    That's better

     pictureBox.Image = Properties.Resources.картинка;