You want to create a stream that you can use to store a file temporarily while your
application processes data. After all data processing is complete, you want to
write it to the file system. It’s important that you minimize the time that the file
is locked. Which class should you use?

When you write to a MemoryStream, the data is stored in memory
instead of being stored to the file system. You can then call Memory-
Stream.WriteTo to store the data on the file system permanently