title: StreamWriter and IFormatProvider
body: <p>How do I pass an IFormatProvider to a StreamWriter?</p>
  
  <p>Specifically I want to create a<br>
  <code>new StreamWriter("myfile.txt", CultureInfo.InvariantCulture);</code></p>
  
  <p>TextWriter and StringWriter have a parameter for that in the constructor, but StreamWriter does not.<br>
  The Property stringWriter.FormatProvider is readonly.</p>
  
  <p>I could think of three workarounds that seem like bad solutions:</p>
  
  <ul>
  <li>Changing Thread.CurrentCulture: This is going to be in a library, so I'd rather not change any global settings, even temporarily.</li>
  <li>sw.WriteLine(InvariantCulture, , ): There are a lot of sw.WriteLine() over several functions. I'd really like to avoid messing with all of them.</li>
  <li>using a StringWriter first and then writing the string to a file: since the stream can get very big, this will incur a huge overhead.</li>
  </ul>
  
  <p>Is there any way to specify a FormatProvider for StreamWriter? Based on Inheritance from TextWriter, the StreamWriter must have the means to handle this, if I could just set the property.</p>