blah blah blah is here! blah blah » Close

up0down
link

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;

last answered one month ago

1 answers

up0down
link

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.

Feedback