Skip to content

Instantly share code, notes, and snippets.

@Microsofttechies
Created May 8, 2015 00:12
Show Gist options
  • Select an option

  • Save Microsofttechies/e2214563c4a4c91cdf82 to your computer and use it in GitHub Desktop.

Select an option

Save Microsofttechies/e2214563c4a4c91cdf82 to your computer and use it in GitHub Desktop.
C# Append lines to a file using a StreamWriter
StringBuilder strBuilLog = new StringBuilder();
string strLogData = "Welcome to log data \t";
strBuilLog.Append(strLogData);
string strLogData2 = "Welcome to log data 2" + Environment.NewLine;
strBuilLog.Append(strLogData2);
string strLogDataFinal = "Welcome to log data final \t";
strBuilLog.Append(strLogDataFinal);
using (StreamWriter strwLog = new StreamWriter("c:\\log.txt"))
{
strwLog.Write(strBuilLog.ToString());
strwLog.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment