本文介绍了将大文本文件读入列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好, 我一直在搜索但未找到答案。也许有人可以提供帮助? 为什么: Dim PointArray() as String PointArray = System.IO.File。 ReadAllLines(MyFileName) 效果很好而且速度非常快,但我找不到类似的方法在List中做同样的事情: Dim PointList As 新列表( 字符串) PointList = System.IO.File。 ReadAllLines(MyFileName) 我正在尝试使用List而不是数组,因为我相信它在处理数据时比数组更快,而MyFileName包含大约300,000行。 br /> 谢谢解决方案 你做错了! 您必须使用OleDb读取此类数据! 这个想法是: 1)将数据加载到DataTable中 [ ^ ]使用 OleDbReader [ ^ ] 2)使用Linq to DataSet [ ^ ]进行计算 关注个是链接 [ ^ ]查看我过去的答案。 进一步信息,请参阅: 关于文本文件的大量ADO [ ^ ] 文本文件连接字符串 [ ^ ] 如何:使用Jet OLE DB Provider 4.0连接到ISAM数据库 [ ^ ] Schema.ini文件(文本文件驱动程序) [ ^ ] 使用OleDb导入文本文件(选项卡,CSV,自定义) [ ^ ] 如何使用Jet提供程序的Text IIsam打开分隔文本文件 [ ^ ] LINQ to DataSet示例 [ ^ ] LINQ to DataSet中的查询 [ ^ ] 查询数据集(LINQ to DataSet) [ ^ ] Hello,I've searched around but not found an answer to this. Perhaps someone can help?How come:Dim PointArray() as StringPointArray = System.IO.File.ReadAllLines(MyFileName)Works well and is really fast, but I cant find a similar method for doing the same into a List as below:Dim PointList As New List(Of String)PointList = System.IO.File.ReadAllLines(MyFileName)I'm trying to use a List rather than an Array as I believe its faster than an array when handling data and MyFileName contains around 300,000 lines.Thanks 解决方案You're doing it wrong!You have to read such of data using OleDb!The idea is:1) load data into DataTable[^] using OleDbReader[^]2) use Linq to DataSet[^] to make calculationFollow this link[^] to see my past answers.For further information, please see:Much ADO About Text Files[^]Textfile connection strings[^]HOW TO: Use Jet OLE DB Provider 4.0 to Connect to ISAM Databases[^]Schema.ini File (Text File Driver)[^]Using OleDb to Import Text Files (tab, CSV, custom)[^]How To Open Delimited Text Files Using the Jet Provider's Text IIsam[^]LINQ to DataSet Examples[^]Queries in LINQ to DataSet[^]Querying DataSets (LINQ to DataSet)[^] 这篇关于将大文本文件读入列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!