Hello I have a StreamWriter Called gameWriter. Can I use string builder to format my Stream Writer? I want the result to look like this: playerOneName and playerTwoName are variables that need to be written. Can someone show me a sample code to show the following:
Output:
playerOnename, playerTwoname, _, _, _, _, _, _, _, _, _,
private void WriteData(string playerOneName, string playerTwoName)
{
StreamWriter gameStateWriter = null;
try
{
gameStateWriter = new StreamWriter(filepath, true);
gameStateWriter.WriteLine(playerOneName + " , " + playerTwoName);
}
catch (Exception ex)
{
txtOutcome.Text = "The following problem ocurred when writing to the file:\n"
+ ex.Message;
}
finally
{
if (gameStateWriter != null)
gameStateWriter.Close();
}
}
Yes those are underscores, they are suppose to represent spaces are ready to be written on to hold some text.
i am using Visual Studio ’08 running ASP.NET website and form.
That how to use stream writer with string builder although i would recommend use a loop to append to builder.
you just store all your variables in array