title: How can I format my Stream Writer to write to my text file?
body: <p>The text file is being used to describe the state of the game on a web browser. So I need to format my nameWriter.WriteLine to look something like.</p>
  <pre><code>Output to text file:
  playerOneName, playerTwoName, _ , _ , _ , _ , _ , _ , _ , _
  </code></pre>
  <p>I know this may sound like &quot;Oh just writeLine this!&quot; But no, the underscores are an empty field that are to be replace by my StreamWriter, it tracks the moves of the player in a tic tac toe web game. What can I use instead of the underscore to make that space available for my read and write?</p>
  <p>Here is my StreamWriter, right now I only have it adding the player name.</p>
  <h3>Can you show me how to format the output to text?</h3>
  <p>Maybe separate it in an array? and use a array DelimiterList to key out the commas?</p>
  <pre><code>    string[] lineParts... and reference the linePart[0-11] 
  and then do a lineParts = line.Split(delimiterList)?
  </code></pre>
  <p>Here is my write code.</p>
  <pre><code>private void WriteGame(string playerOneName, string playerTwoName, string[] cells)
      {
          StreamWriter gameStateWriter = null;
          StringBuilder sb = new StringBuilder();
          try
          {
              gameStateWriter = new StreamWriter(filepath, true);
              gameStateWriter.WriteLine(playerOneName + &quot; , &quot; + playerTwoName);
              string[] gameState = { playerOneName, 
              playerTwoName, null, null, null, null, 
      null, null, null, null, null };//I cannot use null, they will give me errors
              foreach (string GameState in gameState)
              {
                  sb.Append(GameState);
                  sb.Append(&quot;,&quot;);
              }
              gameStateWriter.WriteLine(sb.ToString());
          }
          catch (Exception ex)
          {
              txtOutcome.Text = &quot;The following problem ocurred when writing to the file:\n&quot;
                 + ex.Message;
          }
          finally
          {
              if (gameStateWriter != null)
                  gameStateWriter.Close();
          }
      }
  </code></pre>
  <p><strong>Lastly if playerOneName is already in the text file, how do I specifically write playerTwoName after it and check that it is there?</strong></p>
  <p>Using Visual Studio '08 ASP.NET website and forms</p>