I was trying to make smth like this... Basically im trying to shuffle music by their names. Everything works nicely, but i was wondering if theres a way for tihs random funcion not to repeat same numbers?
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
button1.Enabled = true;
DirectoryInfo dir = new DirectoryInfo(comboBox1.SelectedItem.ToString());
count = dir.GetFiles().Length;
label3.Text = "Files loaded: " + count.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
DirectoryInfo d = new DirectoryInfo(comboBox1.SelectedItem.ToString());
FileInfo[] infos = d.GetFiles("*.mp3");
int i = 1;
foreach (FileInfo f in infos)
{
File.Move(f.FullName, Path.Combine(f.DirectoryName, i + ". " + f.Name));
i = rnd.Next(1, count+1);
}
}
Aucun commentaire:
Enregistrer un commentaire