using System;
using System.IO;
public class MainClass
{
public static int Main(string[] args)
{
MemoryStream myMemStream = new MemoryStream();
myMemStream.Capacity = 256;
for(int i = 0; i < 256; i++)
myMemStream.WriteByte((byte)i);
myMemStream.Position = 0;
for(int i = 0; i < 256; i++)
Console.Write(myMemStream.ReadByte());
Console.WriteLine();
FileStream dumpFile = new FileStream("Dump.dat",
FileMode.Create, FileAccess.ReadWrite);
myMemStream.WriteTo(dumpFile);
byte[] bytesinMemory = myMemStream.ToArray();
myMemStream.Close();
for(int i = 0; i < bytesinMemory.Length; i++)
Console.Write(bytesinMemory[i]);
return 0;
}
}
Thoughts on C#, .NET, programming, software development and productivity. Tips and tricks to solve various programming problems.
Tuesday, May 24, 2011
Write Bytes to Memory Stream
Labels:
.NET Framework
,
C#
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment