StringBuilder sb=new StringBuilder();
Sb. AppendLine ($" first line ");
Foreach (Mapping item in MapData)
{
Sb. AppendLine (item. The ToString ());
}
//store
String DicFilePath=Path.Com bine (BaseInfo ProjectName, ProjectName + "_Dic. TXT");
If (the File. The Exists (DicFilePath) File. Delete (DicFilePath);
Var fs=new FileStream (DicFilePath, FileMode. Append, FileAccess. Write FileShare. ReadWrite);
Using (StreamWriter sw=new StreamWriter (fs, Encoding GetEncoding (" gb2312 ")))
{
Sw. Write (sb. ToString ());
}
Fs. The Close ();
The final text file will always be a blank line, and more consult how to solve?
CodePudding user response:
Appendline lines end with a newline, append not
Sb. AppendLine (item. The ToString ());
Sb. Append (item. The ToString ());
CodePudding user response:
Append
Line you require Line ah,
CodePudding user response: