dimanche 3 janvier 2016

C# Random set of images [duplicate]

This question already has an answer here:

I have a file with 4 images in it. I have to show them randomly in 4 PictureBoxes. I have put the images in image array. The Problem is I have to use Random Function to shuffle images randomly and I don't know how. I have shuffled them by hand. So far this is the code:

//Making Image Array:

    Image[] img = new Image[4];
    static string fpath = @"Images Folder Path";
    string[] imgpath = System.IO.Directory.GetFiles(fpath, "*.jpg");

//Load images:         

        pictureBox1.Image = Image.FromFile(imgpath[2]);
        pictureBox2.Image = Image.FromFile(imgpath[1]);
        pictureBox3.Image = Image.FromFile(imgpath[0]);
        pictureBox4.Image = Image.FromFile(imgpath[3]);




Aucun commentaire:

Enregistrer un commentaire