C# Problem: Attached is a text file that contains theses song. The file contains
ID: 658217 • Letter: C
Question
C# Problem:
Attached is a text file that contains theses song. The file contains 500 lines. Each line has
- Rank of song
-Artist
- Song Title
Create a database application that contains a table with three columns; Rank of song, artist, and song title.
Open the text file and read each line; tokenize the line to extract rank, artist, and song title. Then, for each line you should use the SQL insert command (via a method) to create a new tuple (record) in the table
------------------------------------------------------------------------------------------------------------------------------------------------
I already have the database application made in the designer called songsDataGridView. I need help forming a code that will tokenize each line in the text file, and insert each line as a record in songsDataGridView, using button_click called importButton. here is my designer view
Explanation / Answer
public static object GetSongList(bool lib = true, bool albumArt = true)
{
MediaLibrary mediaLib = new MediaLibrary();
var songs = mediaLib.Songs;
if (lib)
{
return songs;
}
else
{
var list = new List<MusicTitle>();
foreach (var song in songs)
{
list.Add(new MusicTitle()
{
Artist = song.Artist.Name,
Title = song.Name,
Duration = (new DateTime(song.Duration.Ticks)).ToString("mm:ss"),
Album = song.Album.Name,
Art = albumArt ? GetAlbumArt(song, 100) : null
});
}
return list;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.