Created
November 20, 2018 02:58
-
-
Save unity3dcollege/0a7c05a7d9017aa16abc6e8849c5850a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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