最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
一个读写csv文件的C#类
时间:2022-06-25 07:49:21 编辑:袖梨 来源:一聚教程网
代码如下 | 复制代码 |
using System; using System.Collections.Generic; using System.IO; using System.Text; namespace CSVDemo { /// /// CSVUtil is a helper class handling csv files. /// public class CSVUtil { private CSVUtil() { } //write a new file, existed file will be overwritten public static void WriteCSV( string filePathName,List { WriteCSV(filePathName, false ,ls); } //write a file, existed file will be overwritten if append = false public static void WriteCSV( string filePathName, bool append, List { StreamWriter fileWriter= new StreamWriter(filePathName,append,Encoding.Default); { fileWriter.WriteLine(String.Join (“,",strArr) ); } fileWriter.Flush(); fileWriter.Close(); } public static List string filePathName) { List new List StreamReader fileReader= new StreamReader(filePathName); string strLine= "" ; while (strLine != null ) { strLine = fileReader.ReadLine(); if (strLine != null && strLine.Length>0) { ls.Add(strLine.Split( ',' )); //Debug.WriteLine(strLine); } } fileReader.Close(); return ls; } } } |
相关文章
- 原神挪德卡莱供奉点位在哪 挪德卡莱供奉点位置分享 09-16
- 无主之地4支线任务适配肢体怎么做 支线任务适配肢体图文攻略 09-16
- 崩坏星穹铁道3.6版本抽数统计一览 09-16
- 原神操作盈月之镜内的机关操作流程 09-16
- 地下城堡4骑士与破碎编年史军团币获取途径 09-16
- 无主之地4支线任务适配肢体归来怎么完成 支线任务适配肢体归来图文攻略 09-16