sLine = objReader.ReadLine();
DataRow dr = dt.NewRow();
int i = 0;
while (sLine != null)//是否是最后
{
string Columnstext = "";
if (sLine.IndexOf(',') > 0)
{
Columnstext = sLine.Substring(0, sLine.IndexOf(','));
sLine = sLine.Substring(Columnstext.Length + 1, sLine.Length - Columnstext.Length - 1);
dr.ItemArray[i] = Columnstext;
}
else if (sLine.IndexOf(',') == 0)
{
dr.ItemArray[i] = "";
sLine = sLine.Substring(1, sLine.Length - 1);
} else
{
dr.ItemArray[i] = sLine;
Label1.Text = sLine;
sLine = null;
}
i++;
}
dt.Rows.Add(dr);
DataRow dr = dt.NewRow();
int i = 0;
while (sLine != null)//是否是最后
{
string Columnstext = "";
if (sLine.IndexOf(',') > 0)
{
Columnstext = sLine.Substring(0, sLine.IndexOf(','));
sLine = sLine.Substring(Columnstext.Length + 1, sLine.Length - Columnstext.Length - 1);
dr.ItemArray[i] = Columnstext;
}
else if (sLine.IndexOf(',') == 0)
{
dr.ItemArray[i] = "";
sLine = sLine.Substring(1, sLine.Length - 1);
} else
{
dr.ItemArray[i] = sLine;
Label1.Text = sLine;
sLine = null;
}
i++;
}
dt.Rows.Add(dr);
if (sLine.IndexOf(',') > -1)
{
Columnstext = sLine.Substring(0, sLine.IndexOf(','));
sLine = sLine.Substring(Columnstext.Length + 1, sLine.Length - Columnstext.Length - 1);
dr.ItemArray[i] = Columnstext;
}