title: Encode a FileStream to base64 with c#
body: <p>I know how to encode / decode a simple string to / from <strong>base64</strong>. </p>
  
  <p>But how would I do that if the data is already been written to a <strong>FileStream</strong> object. Let's say I have only access to the FileStream object not to the previously stored original data in it. How would I encode a <strong>FileStream to base64</strong> before I flush the FileStream to a file. </p>
  
  <p>Ofc I could just open my file and encode / decode it after I have written the FileStream to the file, but I would like to do this all in one single step without doing two file operations one after another. The file could be larger and it would also take double time to load, encode and save it again after it was just saved a short time before. </p>
  
  <p>Maybe someone of you knows a better solution? Can I convert the FileStream to a string, encode the string and then convert the string back to a FileStream for example or what would I do and how would such a code look like? </p>