I have a folder [Souds\Backgrounds] full on Midi files which I can play using a function [PlayMidiFile(string MidiFile)] and everything works fine...
Thing is this folder [Souds\Backgrounds] has a large amount of Midi files (and some other non-music files that must be ignored) and I want my program to randomly choose one everytime it starts...
So, essentially I want to pass into [PlayMidiFiles] a string (MidiFile) representing the filename (with path) of a randomly selected Midi file in the [Souds\Backgrounds] folder...
So far this is what I have, I am able to get a string[] with a list of all the possible midi files, but now how do I RANDOMLY select one?
So, I need to somehow fill the string variable "sSelected" with one of the random values in "sFileList"
Any ideas, hints, and help would be greatly appreciated, thanks
Thing is this folder [Souds\Backgrounds] has a large amount of Midi files (and some other non-music files that must be ignored) and I want my program to randomly choose one everytime it starts...
So, essentially I want to pass into [PlayMidiFiles] a string (MidiFile) representing the filename (with path) of a randomly selected Midi file in the [Souds\Backgrounds] folder...
So far this is what I have, I am able to get a string[] with a list of all the possible midi files, but now how do I RANDOMLY select one?
Code:
string sSelected = null;
string[] sFileList = System.IO.Directory.GetFiles("Sounds\\Backgrounds", "*.mid");
// ... Randomly select one of the strings from sFileList[] and put it in sSelected ...
// Play Selected File
if (PlayMidiFile(sSelected) == 0)
return true;
else
return false;
Any ideas, hints, and help would be greatly appreciated, thanks