i'm trying to get three different images chosen randomly from a directory,
i got one, but i need to subtract the one i got from the possible outcome for the remaining to get the second and the same way for the third..
var files = Directory.GetFiles("c:\\Photos", "*.jpg");
var rand = new Random();
imgFile = files[rand.Next(files.Length)];
pictureBox1.ImageLocation = imgFile;

1 answers
Have you tried putting the filenames in the folder into a list<> then picking one at random and removing it from the list? That should allow you to do what you're attempting.
answered one month ago by:
208