我想将所有数据从我的csv
返回到txt文件string fileName = "../../TechFiles/";
List<string> listA = new List<string>();
using (var reader = new StreamReader(ConfigurationManager.AppSettings["ConfigurationSource"]))
{
var hdr2 = "2012-05-09 12:52:00";
var hdr1 = "Account";
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(',');
listA.Add(values[0]);
csv = new StringBuilder();
newLine = string.Format("HDR {0} {1}\r\n{2}{3}" , hdr1,line, Environment.NewLine);
csv.Append(newLine);
File.WriteAllText(String.Format("{0}{1}", fileName, values[4] + ".txt"), csv.ToString());
}
}
答案 0 :(得分:2)
使用File.AppendAllText
:
File.AppendAllText(String.Format("{0}{1}", fileName, values[4] + ".txt"), csv.ToString());