C# save pdf stream to file

C#
using (var fileStream = File.Create("C:\\Path\\To\\File"))
{
    myStream.Seek(0, SeekOrigin.Begin);
    myStream.CopyTo(fileStream);
}
Source

Also in C#: