// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; class MainClass { public static void Main(string[] args) { FileStream fs = new FileStream(@"C:\bin.dat", FileMode.Open, FileAccess.ReadWrite); for(int i = 0; i < fs.Length - 1; i++) { byte[] b = new byte[2]; fs.Seek(i, SeekOrigin.Begin); fs.Read(b, 0, b.Length); if(b[0] == 'b' && b[1] == 'b') { b[0] = (byte)'_'; b[1] = (byte)'_'; fs.Seek(i, SeekOrigin.Begin); fs.Write(b, 0, b.Length); } } fs.Close(); } }