samedi 9 juillet 2022

How to get filename from random picturebox?

I have a question, i'm making guess app and on click button picturebox get random image from directory.

Random rnd = new Random();
       

        private void random_Click(object sender, EventArgs e)
        {
            string folder = @"D:\folder";
            string[] files = Directory.GetFiles(folder);

                pictureBox1.ImageLocation = files[rnd.Next(files.Length)];
              
            }

And now i want make if statement. If picture name is "apple.png" do this, if "orange.png" do this. Can i make something like this?

Cheers and have a good day!




Aucun commentaire:

Enregistrer un commentaire