为了以后自己方便查找,记录下来:
1. 引用命名空间, using Microsoft.VisualBasic.FileIO;
2. 关键代码:
var reader = new StreamReader(File.OpenRead(path1)); string[] values = null; using (var csvReader = new TextFieldParser(reader)) { while (!csvReader.EndOfData) { csvReader.SetDelimiters(new string[] { "," }); csvReader.HasFieldsEnclosedInQuotes = true; values = csvReader.ReadFields(); } }
时间: 2024-10-13 02:37:53