// The ToArray() method is like the ToString method in that it helps the contructor pass the correct objects to the array in the correct form
 public string[] ToArray()
 {
     return(new string[]
     {
         VideoID.ToString(),
         VideoName,
         QuantityInStock.ToString(),
         QuantityCheckedOut.ToString(),
         TotalQuantity.ToString(),
         MediaType,
         DownloadType,
         Price.ToString(),
         GenreID.ToString(),
         Genre,
         Adult,
     });
 }
Exemple #2
0
        // Found someplace random on the net.  Replace this soon, it barely f*****g works.
        private Song ReadTag(string filename)
        {
            string Title;
            string Artist;
            string Album;
            string Year;
            string Comment;
            int    GenreID;
            int    Track;

            FileStream oFileStream;

            byte[] bBuffer;

            oFileStream = new FileStream(filename, FileMode.Open);
            bBuffer     = new byte[128];
            try{
                oFileStream.Seek(-128, SeekOrigin.End);
                oFileStream.Read(bBuffer, 0, 128);
            }
            catch (System.IO.IOException) {
                oFileStream.Close();
                Song tempSong = new Song(filename, "ErrorNoSongTitle", "", "", "", "", "", "");
                return(tempSong);
            }

            Encoding instEncoding = new ASCIIEncoding();
            string   id3Tag       = instEncoding.GetString(bBuffer);

            if (id3Tag.Substring(0, 3) == "TAG")
            {
                Title   = id3Tag.Substring(3, 30).Trim();
                Artist  = id3Tag.Substring(33, 30).Trim();
                Album   = id3Tag.Substring(63, 30).Trim();
                Year    = id3Tag.Substring(93, 4).Trim();
                Comment = id3Tag.Substring(97, 28).Trim();

                if (id3Tag[125] == 0)
                {
                    Track = bBuffer[126];
                }
                else
                {
                    Track = 0;
                }
                GenreID = bBuffer[127];

                String newTitle  = "";
                String newArtist = "";
                String newAlbum  = "";

                foreach (char x in Title.ToCharArray())
                {
                    if (x != '\0')
                    {
                        newTitle += x;
                    }
                }

                foreach (char x in Artist.ToCharArray())
                {
                    if (x != '\0')
                    {
                        newArtist += x;
                    }
                }
                foreach (char x in Album.ToCharArray())
                {
                    if (x != '\0')
                    {
                        newAlbum += x;
                    }
                }

                Song tempSong = new Song(filename, newTitle, newArtist, newAlbum, Track.ToString(), GenreID.ToString(), Year, Comment);
                return(tempSong);
            }
            else
            {
                Song tempSong = new Song(filename, "ErrorNoSongTitle", "", "", "", "", "", "");
                return(tempSong);
            }
        }