c语言csv格式数据文件的读写 C#如何读取csv文件?
C#如何读取csv文件?使用StreamReader打开文件,使用readLine方法逐行读取CSV文件的内容,使用readtoend方法一次读取CSV文件的所有内容,您可以逐行读取字符串,然后使用s
C#如何读取csv文件?
使用StreamReader打开文件,使用readLine方法逐行读取CSV文件的内容,使用readtoend方法一次读取CSV文件的所有内容,您可以逐行读取字符串,然后使用split方法按“,”将内容分成数组。代码如下:StreamReader=new StreamReader(“file full path or relative path,including file name”)string line=“”list<string[]> liststrarr=new list<string[]>()//array list,相当于可以无限扩展的二维数组。直线=读卡器.ReadLine()//读取一行数据,同时(行!=空){listStrArr.添加( 行。拆分(“,”)//将文件内容拆分为数组=读卡器.ReadLine()}