Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Created November 20, 2018 02:58
Show Gist options
  • Save unity3dcollege/0a7c05a7d9017aa16abc6e8849c5850a to your computer and use it in GitHub Desktop.
Save unity3dcollege/0a7c05a7d9017aa16abc6e8849c5850a to your computer and use it in GitHub Desktop.
using System.IO;
namespace binarywritertest
{
class Program
{
static void Main(string[] args)
{
byte[] data = new byte[100];
for (byte i = 0; i < 100; i++)
{
data[i] = (byte)(i+100);
}
File.WriteAllBytes(@"c:\temp\array-writeall.dat", data);
using (BinaryWriter bw = new BinaryWriter(File.Open(@"c:\temp\array-binarywriter.dat", FileMode.OpenOrCreate)))
{
bw.Write(data);
}
using (FileStream fileStream = new FileStream(@"c:\temp\array-filestream.dat", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
{
fileStream.Write(data, 0, 100);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment