Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 ?!!)



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..
Posted
Comments
Kenneth Haugland 14-Jun-15 12:09pm    
Why not compress them into a single file?

Hi
I would most likely use a zip archive for this it will give you a lot of things out of the box, this is even how microsoft formats are beeing built. Try renaming a word file (.docx) to a (.zip) and decompress it and you will see.

Try following article I just googled
http://www.tugberkugurlu.com/archive/net-4-5-to-support-zip-file-manipulation-out-of-the-box[^]

Another option would be to create your own format which will be more work but not necessarily complicated.
you start with writing a header which contains information about the files like name and size and then you concatinate the files after this. This should definetly be done on a binary level and not make use of any excisting formats like XML or Json or whatever you can come up with.

Header could look like, use some token that is not accepted in a filename like []
[int32 containing nr Of files]
[filename1][size1 as int64 8 bytes]
[filename2][size2 as int64 8 bytes]
[filename3][size3 as int64 8 bytes]
[filename4][size4 as int64 8 bytes]

after the header you just concatinate the files since you know the file size of each file is should be easy to extract them later
 
Share this answer
 
I'd suggest you look at putting them in a ZIP file (With a password if necessary) - SharpZipLib[^] is pretty good, or there are loads of articles here on the subject: Google[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900