1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| using Microsoft.Office.Interop.Excel; using Microsoft.VisualBasic.FileIO;
public List<string> ReadFromCsv() { var partList = new List<string>(); using (TextFieldParser parser = new TextFieldParser(@"D:/List.csv")) { parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(","); while (!parser.EndOfData) { string[] fileds = parser.ReadFields(); foreach (var filed in fileds) { partList.Add(filed); } } } return partList; }
|