如何逃避","用于编写CSV文件

时间:2018-06-11 00:35:45

标签: c# csv

我有这样的变量:

string text1 = "its my text";
string text2 = "really";
string text3 = "it's mine";

我有字符串构建器:

StringBuilder csvcontent = new StringBuilder();

我将所有字符串连接成一个:

string forAppend = text1+ "," + text2 + "," + text3 + ",";
csvcontent.AppendLine(forAppend);

我将它们与","分开。因为我希望他们在excel中分离单元格。最后一步我将这些数据写入excel:

File.AppendAllText(path, csvcontent.ToString());

它运作良好。但如果我有","在一个字符串中它分隔单元格。我只想拥有3个单元格,我怎样才能逃脱#34;,"在字符串变量?

0 个答案:

没有答案