C# 字符串写入文件

会覆盖已存在文件
File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "abv.json"), "创建连接字符串开始");

true不会覆盖已存在文件
StreamWriter sw = new StreamWriter(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "abv.json"), true);
sw.Write("创建连接字符串结束");
sw.Close();

原文地址:https://www.cnblogs.com/wa502/p/11603630.html