Skip to content

Merge several different files into a single file using c#

mina barzegar

Asked Jun 14, 2015, 7:53 AM EDT1 answer
Share
LinkedInX
I need to combine multiple files (video & music & text) into single file with a custom file type (for example: *.abcd) and custom file data structure , and the file should only be read by my program and my program should be able to separate parts of this file. How do this in .net & c#? -- my file has any size , for example 300 MB , 500 MB or 1 GB and merged file's size is about 1.5 or 2 GB , how i do it ? .. (using stream or memory stream ?!!)
 
 
Code
https://www.imageupload.co.uk/image/ZWnh
My program is similar to Microsoft Power Point .in pptx file you can put your texts and videos and then save the file with *.pptx format and load it anytime...

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    The best way to do this will depend on whether your program will need to display and playback everything or only store things "as is".
    If you're going to simply store them then extract them later, all you need is a simple directory structure that you store at the beginning. This directory will have information such as offset, size, type and original file name of each section. You can then dump the different files as sections after the header.
    You could also apply encryption on the segments before saving them. This post discusses this:
    http://stackoverflow.com/questions/5090233/how-to-encrpyt-decrypt-data-in-chunks

    The real problem will be if you want to play back the video and music in your application and not just store them. Depending on which mix of formats you want to support, you might want to use an SDK that has strong support for different formats such as Leadtools.
    0