Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Buddies:

I wonder if you could guide me through creating one file that consist of all data type such as picture, string, mp3 and MathType equation in just one file.

I can use the rtf format to do this. However, the number of these data types are enormous for example 1000 collection of [string, pic., video, and sound] in just one file and as a result the time of reading goes to the roof.

1. What is the best approach to do this?

2. Is there any way to convert the sound and video and equations to the language of computer in order to have high speed in reading data?

3. I must also use a format that users cannot modify or access or understanding the content of file. How should I solve this challenge?


YOURS SINCERELY
GRACIAS.
Posted
Updated 4-Mar-12 2:10am
v3
Comments
Uday P.Singh 4-Mar-12 5:41am    
not clear! what are you trying to achieve here?

I mean that you need to write each file section as a binary image, i.e. copy from its original location as a binary stream, into the new file. As you add each section you create an index (of your own design) which contains the file offset, length, and any other relevant information. After adding the last binary image to your file you then write your index (making a note of its file offset), and then finally write that offset location to the file, so that you can find the index when reading. Your file will then look something like:

Data file 1 (mp3)
Data file 2 (txt)
Data file 3 (avi)
Data file 4 (pdf)
Index
pointer to index

The Index is just a table which contains the pointers to the data files.

In order to read any file you just need to find the index (from the last word in the file), get the offset and length of the file, and read from that point.

An alternative solution would be to use SQL Compact Edition which would give you equal control, but with a ready made program to control the management of your data, allowing insertion, updating and extraction with the minimum amount of work on your part.
 
Share this answer
 
Comments
Mmohmmad 4-Mar-12 7:09am    
Dear Richard:

Thanks for your help.

which class and method should I use in order to write my data in a binary image format in C#?

Yours
Richard MacCutchan 4-Mar-12 7:26am    
The BinaryWriter and associated classes should provide what you need.
Mmohmmad 4-Mar-12 7:55am    
Thanks for your nice clues my friend
Richard MacCutchan 4-Mar-12 7:59am    
Happy to help. Don't forget to click on "Accept Solution" for me.
Shahin Khorshidnia 4-Mar-12 10:38am    
+5, Very nice and clean.
You could use something like the approach taken in the format of PDF files. The actual data (of any type) is written to the file in any order, but the location and length of each sub-file is held in an index which is written at the end of the file when it's complete. You can then access any part of the file from the index which would allow you to read it just as fast as if it were a separate file.
 
Share this answer
 
Comments
Mmohmmad 4-Mar-12 6:12am    
Dear Richard:

Thanks for your nice clues. I really think that it is a nice approach. You explain it in a way that there must not be further questions. However I need some help.

you said that location of each file is held in an index. so for example I incorporate my mp3s videos and etc. to the Word Pad and now how should I store the location of these files in indexes?

In the last line you said that "if it were a separate file". what do you mean by that?

Yours

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