title: How to cast from Stream to FileStream in C#
body: <p>I have a <code>Stream</code> type &quot;outputStream&quot; that I got from MailMerger that I need to return as <code>FileStream</code>.</p>
  <p>I know that <code>FileStream</code> extends <code>Stream</code>, but is there a way to transfer content to Stream or maybe cast the type?</p>
  <p>Any ideas on how to change the type?</p>
  <pre><code>        static FileStream IMailMergeService(Dictionary&lt;string, string&gt; dataSource, Stream stream)
          {
              var (outputStream, errors) = new MailMerger().Merge(stream, dataSource);
  
              return (FileStream)outputStream;
          }
  </code></pre>
  <p><a href="https://www.nuget.org/packages/MailMerge/" rel="nofollow noreferrer">This is the MailMerger used</a></p>