Skip to content

Instantly share code, notes, and snippets.

@Tustin
Created July 15, 2017 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tustin/fe1a75b81a3c0f4e2db9694214334ac0 to your computer and use it in GitHub Desktop.
Save Tustin/fe1a75b81a3c0f4e2db9694214334ac0 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
namespace pkg_merge
{
public class Program
{
static void Main(string[] args)
{
Directory.GetFiles("pkgs");
byte[] buffer = new byte[1024 * 1024];
using (var br = new BinaryReader(File.Open("pkgs/UP2050-CUSA01340_00-DUNDEF2000000PS4-A0151-V0100_0.pkg", FileMode.Open)))
using (var br2 = new BinaryWriter(File.Open("pkgs/test.pkg", FileMode.Append)))
{
long fileSize = br.BaseStream.Length;
long totalRead = 0;
while (totalRead < fileSize)
{
var read = br.Read(buffer, 0, buffer.Length);
br2.Write(buffer, 0, buffer.Length);
totalRead += read;
Console.Write($"Read {totalRead}/{fileSize} bytes\r");
}
}
Console.WriteLine("\r\ndone");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment