【发布时间】:2023-01-01 20:35:49
【问题描述】:
我想从一个 .txt 文件中读取文本数据,其中的数据是制表符分隔. 我正在粘贴下面的示例数据。 [1]:https://i.stack.imgur.com/t9cPt.png
现在我想要的是将数据读入一个列表类型细绳 没有标题.
我目前有以下代码:
var sepList = new List<string>();
// Read the file and display it line by line.
using (var file = new StreamReader(docPath))
{
string line;
while ((line = file.ReadLine()) != null)
{
var delimiters = '\t';
var segments = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
foreach (var segment in segments)
{
//Console.WriteLine(segment);
sepList.Add(segment);
}
}
}
任何帮助将不胜感激:)[![在此处输入图片描述][1]][1]
【问题讨论】:
标签: c# filestream