How appending 2 binary files (pictures) into another binary file

Posted on 2005-05-08
Last Modified: 2010-05-18

I would like to know how I've to append 2 (or more) binary files to a third new(or already existing) binary file. (binary files = in my case pictures)

What kind of stream do I've to use (binary, memory, filestreamer, ... ?????)

If someone could send me a sample, I would really appreciate!



Question by:davyberroho
    LVL 20

    Expert Comment

    What's the idea? If you have 2 pictures in 1 file the will become unusable...
    LVL 14

    Expert Comment

    You should use a bytestream to read in the pixel information, then you need to make a new picture with the approriate size and then you need to do some Maths to calculate the apprioriate pixel value for it.

    Author Comment

    TheAvenger  : I just want to stock lots of images in a large file. (archiving)
    LVL 37

    Accepted Solution

               static void Main(string[] args)
                      FileStream output = null;
                      FileStream input = null;
                            output = File.Open("C:\\foo.bin", FileMode.Append);
                            input = File.Open("C:\\foo2.bin", FileMode.Open);
                            int size = 2048;
                            byte [] data = new byte[size];
                            while((size = input.Read(data,0,size)) != 0)
                      catch (Exception Ex)
                            throw new System.Exception("Unable to append data", Ex);
                            if(output != null)
                            if(input != null)

    just keep in mind that you would need to maintain indexes to where the files are in the big file.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now