Skip to content

Instantly share code, notes, and snippets.

@drch-

drch-/stream.cs Secret

Created February 1, 2013 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drch-/25eb147ef11305171b20 to your computer and use it in GitHub Desktop.
Save drch-/25eb147ef11305171b20 to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
using (var fileStream = new FileStream(@"c:\temp\test.txt", FileMode.Open))
using (var memoryStream = new MemoryStream())
{
fileStream.CopyTo(memoryStream);
byte[] data = memoryStream.ToArray();
Console.WriteLine("Read " + data.Length + " bytes");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment