Binary Writer C Sharp

May 6, 2013 at 09:52:10
Specs: Windows 7
Hi i recently started to learn C Sharp and im trying to merge some binary(bin) files in a folder...I have multiple bin files in a folder which i need to combine to one bin file....Please guide me on this...Thanks guys...

See More: Binary Writer C Sharp

Report •

May 6, 2013 at 11:25:29
copy /b a.bin + b.bin + c.bin allbins.bin

Report •

May 6, 2013 at 12:37:42
Consider the following command line program:
using System;
using System.Linq;
using System.IO;

class Program {
  static void Main(string[] args) {
    const string outName = "combined.bin";
    var files = from f in Directory.EnumerateFiles(@"M:\", "*.bin")
          where f.IndexOf(outName, StringComparison.OrdinalIgnoreCase) < 0
          orderby f
          select f;

    using (var outFile = File.OpenWrite(Path.Combine(@"M:\", outName))) {
      outFile.Seek(0, SeekOrigin.End);
      foreach (var f in files) {
        var fileBytes = File.ReadAllBytes(f);
        outFile.Write(fileBytes, 0, fileBytes.Length);

How To Ask Questions The Smart Way

Report •

Related Solutions

Ask Question