Exemplo n.º 1
0
        private void SearchX(string startingDirectory,Album _Album)
        {
            DirectoryInfo X = new DirectoryInfo(startingDirectory);
            try
            {
                foreach (FileInfo File in X.GetFiles())
                {
                    if (File.FullName.EndsWith(".mp3"))
                    {
                        TagLib.Mpeg.File Sn = new TagLib.Mpeg.File(File.FullName);

                            Song _Song = new Song();
                            _Song.Name = Sn.Tag.Title;
                            _Song.Artist = Sn.Tag.Artists[0];
                            _Album.Songs.Add(_Song);
                            _Song.Type = "application/mp3";
                            _Song.File = File.FullName;

                    }
                    else if (File.FullName.EndsWith(".txt"))
                    {

                        {
                            Song _Song = new Song();
                            _Song.Name = File.Name;
                            _Song.Artist = "Unknown";
                            _Album.Songs.Add(_Song);
                            _Song.Type = "text";
                            _Song.File = File.FullName;
                        }
                    }
                }

                foreach (DirectoryInfo Dir in X.GetDirectories())
                {
                    SearchX(Dir.FullName, _Album);
                }
                }
            catch
            {
            }
        }
Exemplo n.º 2
0
        private void Search(string startingDirectory)
        {
            DirectoryInfo X = new DirectoryInfo(startingDirectory);
            Collection _Collection = new Collection();
            Artist _Artist = new Artist();
            Album _Album = new Album();
            _Collection.Artists.Add(_Artist);
            _Artist.Albums.Add(_Album);
            Collections.Add(_Collection);
            try
            {
                foreach (FileInfo _File in X.GetFiles())
                {
                    if (_File.FullName.EndsWith(".mp3"))
                    {
                        TagLib.Mpeg.File Sn = new TagLib.Mpeg.File(_File.FullName);

                        Song _Song = new Song();
                        _Song.Name = Sn.Tag.Title;
                        _Song.Artist = Sn.Tag.Artists[0];
                        _Album.Songs.Add(_Song);
                        _Song.Type = "application/mp3";
                        _Song.File = _File.FullName;

                    }
                    else if (_File.FullName.EndsWith(".txt"))
                    {

                        {
                            Song _Song = new Song();
                            _Song.Name = _File.Name;
                            _Song.Artist = _File.DirectoryName;

                            _Album.Songs.Add(_Song);
                            _Song.Type = "text";
                            _Song.File = _File.FullName;
                        }
                    }
                    else if (_File.Extension == "exe")
                    {
                        Song _Song = new Song();
                        _Song.Artist = (_File.DirectoryName);
                        _Song.Name = _File.Name;
                        _Song.Type="application/exe";
                        _Album.Songs.Add(_Song);
                    }
                }

                foreach (DirectoryInfo Dir in X.GetDirectories())
                {
                    SearchX(Dir.FullName, _Album);
                }
            }
            catch
            {
            }
            List();
        }