using System;
using System.IO;
using System.Diagnostics;
namespace GenerateBytes
{
class Program
{
static void Main(string[] args)
{
string tempPath = Path.GetTempPath();
for (int i = 0; i < 256; i++)
{
FileStream outStream = File.Create(tempPath + "Byte0x" + String.Format("{0,2:X2}", i) + ".bin");
byte b = Convert.ToByte(i);
outStream.WriteByte(b);
outStream.Close();
}
for (int i = 0; i < 256; i++)
{
FileStream inStream = File.Open(tempPath + "Byte0x" + String.Format("{0,2:X2}", i) + ".bin", FileMode.Open, FileAccess.Read);
byte[] b = new byte[1];
int result = inStream.Read(b, 0, 1);
Debug.Assert(inStream.Length == 1);
Debug.Assert(result == 1);
Debug.Assert(i == Convert.ToInt16(b[0]));
inStream.Close();
}
}
}
}
using System;
using System.IO;
using System.Diagnostics;
namespace GenerateBytes
{
class
Program
{
static
void Main(string[]
args)
{
string tempPath =
Path.GetTempPath();
for (int
i = 0; i < 256; i++)
{
FileStream outStream =
File.Create(tempPath +
"Byte0x" +
String.Format("{0,2:X2}",
i) + ".bin");
byte b =
Convert.ToByte(i);
outStream.WriteByte(b);
outStream.Close();
}
for (int
i = 0; i < 256; i++)
{
FileStream inStream =
File.Open(tempPath +
"Byte0x" +
String.Format("{0,2:X2}",
i) + ".bin", FileMode.Open,
FileAccess.Read);
byte[] b =
new byte[1];
int result =
inStream.Read(b, 0, 1);
Debug.Assert(inStream.Length
== 1);
Debug.Assert(result == 1);
Debug.Assert(i ==
Convert.ToInt16(b[0]));
inStream.Close();
}
}
}
}