Prepending to different file types?

joker77

Active member
Joined
Sep 16, 2005
Messages
38
Location
Dublin
Hi,

This may be a fairly straightforward one, but not having done much work in this area I just wanted to throw it out there

Id like to take a file, and prepend some data to it. This has to be done for several file types:
PowerPoint presentations (.ppt) - take an existing presentation, and insert a new first slide
Word Documents (.doc,.docx) - take a word document, add a new first page
Sound Clips, Podcasts (.mp3,.mwa) - take a clip, and prepend a new start section
Video Clips (.wmv,.mpeg) - same as for sound except with video

Anyay, you get the general jist!

Is this a case of just using a StreamReader and Streamwriter to create a new file based on merging the 2 existing ones??

Thanks
 
The problem I see is that by writing anything to the beginning of any of these file types you will likely damage the headers rendering the files unusable by the programs that use them.

If that isnt a problem, then you should be able to do as you stated above, merge the two files.
 
yea was kind of thinking along those lines myself, the header info would get corrupted.

Maybe someone has done something similar, or theres tools around for various differnet type of files like mpegs, mp3s or Word Documents
 
The technique for each file type would be different. If you just prepend one file to another, most programs will probably only open the prepended data (based on the header from the prepended document) and ignore the remaining data. To do this properly, you have to work with the format of the documents. With office documents you could probably just interop with office. With audio and video files you would probably need special libraries, and even then the particulars can vary from format to format. In other words, you are looking at alot of work.
 
Back
Top