我的代码未读取文本文件的第一行。我已经阅读了类似的问题,并且每次最终都被“ ReadLine”语句使用了两次。但就我而言,我没有。
有人可以发现为什么我的代码仅从第二行开始吗?
我尝试了'do while'语句,但是我不知道执行代码时没有错误。
private void cqaifilesel_SelectedIndexChanged(object sender, EventArgs e)
{
string Qtefile;
Qtefile = System.AppDomain.CurrentDomain.BaseDirectory + @"data\Quote\" + QcomBox.SelectedItem + @"\" + cqaifilesel.SelectedItem;
if (cqaifilesel.Text != "")
{
using (StreamReader read = new StreamReader(Qtefile))
{
string line;
while ((line = read.ReadLine()) != null)
{
string[] tokens = line.Split(new char[] { ',' }, StringSplitOptions.None);
foreach (string sx in tokens)
{
tokens[0] = labelinvnum.Text; tokens[3] = custNametx.Text; tokens[4] = CustNumtx.Text;
tokens[5] = CustCartx.Text;
}
cqaifilesel.Visible = false;
cqaifilesel.SendToBack();
}
}
}
else { }
}
我希望“ StreamReader”读取第一行而不是第二行。