
C#读取若干txt文本中字符串到datagridview中
读取其中的坐标,如-2378571.8583等等到datagridview里,所有文件格式都相同,怎样读取...
读取其中的坐标,如-2378571.8583等等到datagridview里,所有文件格式都相同,怎样读取
展开
3个回答
展开全部
string path = "d:\\log.txt";
using (StreamReader reader = new StreamReader(path))
{
while (true)
{
string strindex = reader.ReadLine();
string begin = string.Empty;
string end = string.Empty;
if (string.IsNullOrEmpty(strindex))
break;
if (Regex.IsMatch(strindex, @"起始点"))
{
begin = strindex;//起始点这一行的字符串 进行截取
}
if (Regex.IsMatch(strindex, @"终止点"))
{
end = strindex;//终止点这一行的字符串 进行截取
}
//添加到datagridview中
}
reader.Close();
}
using (StreamReader reader = new StreamReader(path))
{
while (true)
{
string strindex = reader.ReadLine();
string begin = string.Empty;
string end = string.Empty;
if (string.IsNullOrEmpty(strindex))
break;
if (Regex.IsMatch(strindex, @"起始点"))
{
begin = strindex;//起始点这一行的字符串 进行截取
}
if (Regex.IsMatch(strindex, @"终止点"))
{
end = strindex;//终止点这一行的字符串 进行截取
}
//添加到datagridview中
}
reader.Close();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询