How to Save a Stream to a File in C# ?

Below is a sample code snippet that demonstrates how to save a stream to a file in C#.

How to Save a Stream to a File in C# ?

using (var fileStream = File.Create("E:\\FilePath.txt")) 
{ 
    Object1.InputStream.Seek(0, SeekOrigin.Begin); 
    Object1.InputStream.CopyTo(fileStream); 
}