public List <Track> AddDirectory(List <String> FilesArray) { FilesArray.Sort(); List <String> NewList = new List <String>(); List <String> FilesToAdd = new List <String>(); foreach (String Path in FilesArray) { //if (!File.Exists(Path)) continue; if (IsDirectory(Path)) { string[] FilesTab = Directory.GetFiles(Path, "*", SearchOption.AllDirectories); foreach (string file in FilesTab) { if (IsMusicFile(file)) { FilesToAdd.Add(file); } } } else if (IsMusicFile(Path)) { NewList.Add(Path); } } NewList.AddRange(FilesToAdd); List <Track> Tracks = new List <Track>(); foreach (String file in NewList) { Track track = new Track(file); if (track.IsValid()) { Tracks.Add(track); } } return(Tracks); }
public List <Track> AddDirectory(List <string> FilesArray) { FilesArray.Sort(); var NewList = new List <string>(); var FilesToAdd = new List <string>(); foreach (var Path in FilesArray) { if (IsDirectory(Path)) { var FilesTab = Directory.GetFiles(Path, "*", SearchOption.AllDirectories); foreach (var file in FilesTab) { if (IsMusicFile(file)) { FilesToAdd.Add(file); } } } else if (IsMusicFile(Path)) { NewList.Add(Path); } } NewList.AddRange(FilesToAdd); var Tracks = new List <Track>(); foreach (var file in NewList) { var track = new Track(file); if (track.IsValid()) { Tracks.Add(track); } } return(Tracks); }