【发布时间】:2014-06-18 04:19:39
【问题描述】:
我正在尝试将我现在存储在数组中的特定行从文本文件显示到列表框中。
string[] lines = File.ReadAllLines(@"C:\Users\James Dunn\Documents\Visual Studio 2012\Projects\Assignment 2\Assignment 2\MyJukeBox\bin\Debug\Media\Genre.txt");
mediaLibrary[0] = genreListBox;
for (int l = 3; l < lines.Length; l++)
{
mediaLibrary[0].Items.Add(lines[l]);
}
genreListBox.Items.Add(mediaLibrary[0]);
到目前为止,此代码显示了除前 3 行之外的所有文本。我如何让它在显示我需要的行后停止?我尝试在 for 循环中使用以下内容,但它给了我错误。
int ll = 6; != lines.Length;
我的 txt 文件是这样布局的
3
2
Other
Big Bad John (1961) - Jimmy Dean.mp3
My Ding A Ling - Chuck Berry.mp3
2
Rap
2pac-ghost.mp3
B.I.G-Spit Your Game.mp3
1
Rock
Linkin park-Numb.mp3
【问题讨论】:
-
您需要哪些线路?他们总是坐在特定的索引上吗?
-
什么决定了要显示的行数或行数?
-
我会发布文件的布局,是的,文件是不变的
-
我需要第一种类型的曲目,所以第 4 行和第 5 行
标签: c# listbox text-files