title: How do you use StreamWriter to write to a file
body: <p>ok so heres the issue, i need to write data to a html file to save it, this format allows me to add anchors and links in which will be needed in many of the files</p>
  
  <p>the names can not be predetermined (they will be files for roleplay characters, and places, 1 file per place or character)</p>
  
  <p>heres the code i have so far </p>
  
  <pre><code>private async Task savetest(string name)
      {
  
          //ok so we get the local storage
          StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
  
          //create the character folder
          var dataFolder = await local.CreateFolderAsync("Character",
              CreationCollisionOption.OpenIfExists);
  
          //create the character html
          var file = await dataFolder.CreateFileAsync(name+".html",
          CreationCollisionOption.ReplaceExisting);
  
          //heres where it will get interesting
          using (StreamWriter writer = new StreamWriter(local+"/"+dataFolder+"/"+file))
          { 
              writer.WriteLine("&lt;html&gt;&lt;head&gt;&lt;title&gt;Character File for " + z.charNameFirst + " " + z.charNameSecond + "&lt;/title&gt;&lt;/head&gt;&lt;body&gt;");
              writer.WriteLine("&lt;html&gt;&lt;head&gt;&lt;title&gt;Character File for " + z.charNameFirst + " " + z.charNameSecond + "&lt;/title&gt;&lt;/head&gt;&lt;body&gt;");
              writer.WriteLine("Name: " + z.charNameFirst + " " + z.charNameSecond + " &lt;br&gt;");
              writer.WriteLine("Gender:" + z.charGender+" &lt;br&gt;");
              writer.WriteLine("Race:" + z.charRace + " &lt;br&gt;");
              writer.WriteLine("Class:" + z.charClass + " &lt;br&gt;");
              writer.WriteLine("Gender:" + z.charGender + " &lt;br&gt;");
              writer.WriteLine("&lt;a href=\"#SomeTest\"&gt;SomeTest&lt;/a&gt;&lt;br&gt;");
              writer.WriteLine("&lt;a href=\"#AnotherTest\"&gt;AnotherTest&lt;/a&gt;&lt;br&gt;");
              for (int i = 20; i &gt; 0; i--) 
              { 
                  writer.WriteLine("some test text some test text some test text some test text some test text some test text "); 
              }
  
              writer.WriteLine("&lt;span style=\"font-weight: bold;\"&gt;&lt;a name=\"SomeTest\"&gt;&lt;/a&gt;SomeTest&lt;/span&gt;&lt;br&gt;");
  
              for (int i = 20; i &gt; 0; i--) 
              { 
                  writer.WriteLine("some test text some test text some test text some test text some test text some test text "); 
              }
              writer.WriteLine("&lt;span style=\"font-weight: bold;\"&gt;&lt;a name=\"AnotherTest\"&gt;&lt;/a&gt;AnotherTest&lt;/span&gt;&lt;br&gt;");
  
              for (int i = 20; i &gt; 0; i--) 
              { 
                writer.WriteLine("some test text some test text some test text some test text some test text some test text "); 
              }
  
              writer.WriteLine("&lt;/body&gt;&lt;/html&gt;");
          }
  
      }
  </code></pre>
  
  <p>However, there is an issue with the following line: </p>
  
  <pre><code>using (StreamWriter writer = new StreamWriter(local+"/"+dataFolder+"/"+file))
  </code></pre>
  
  <p>The error message says: </p>
  
  <blockquote>
    <p>The best overloaded method match for 'System.IO.StreamWriter.StreamWriter(System.IO.Stream, System.Text.Encoding)' has some invalid arguments </p>
  </blockquote>
  
  <p>I don't understand why all the examples I have seen use</p>
  
  <pre><code>new StreamWriter(FILENAME) 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>new StreamWriter(FILENAME,true) 
  </code></pre>
  
  <p>for appending data to existing files.</p>
  
  <p>These will be fresh on each run. <code>FILENAME</code> in this case should be 
  <code>&lt;Windows Phone App's Local Storage&gt;/Character/&lt;NAMEOFCHARACTER&gt;.html</code></p>
  
  <p>I have so many tabs open right now that all say this is the way to do it, but it's just not working and I have no idea why.</p>
  
  <p>NOTE: All of this takes place in the <code>MainPage.xaml.cs</code> in the Windows Phone project.</p>