Hey evyerone,
I'm currently working on a small project that would basically be a self hosted music server. Below is my code which, at a high level, goes through every music file in a specified directory and populates a multidimensional array with the ID3 tags and the file name. I was hoping someone could give me an idea on how to speed this up. It works for a small amount of music but with massive amounts of files, its just not practicle.
//Directory that contains music
string musicDirectory = "F:\\My Music\\";
//2D Array to hold each song and its info
string[][] list = new string[Directory.GetFiles(musicDirectory, "*.mp3", SearchOption.AllDirectories).Length][];
//Itterate through the directories and populate array
int i = 0;
foreach (string filePath in Directory.GetFiles(musicDirectory, "*.mp3", SearchOption.AllDirectories)) {
ID3 obj = new ID3(filePath);
list[i] = new string[6];
list[i][0] = obj.FilePath;
list[i][1] = obj.Artist;
list[i][2] = obj.Album;
list[i][3] = obj.Title;
list[i][4] = obj.Genre;
list[i][5] = obj.TrackNumber;
i++;
}
What it basically does is go through each file name and pass it as a constructor paramater to the class, ID3 which initializes the class variables. These are in turn, set to the proper array fields. This array would then be used to populate list boxes on an ASP.net webpage.
Any help would be much appreciated.
Thanks!
-Barefoot