954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

file header reader/writer

Hi everybody,

I would like to know how can i read the header of all sort of of files.

to be more specific, i want to write a function in c# that returns header of any local file.
I wanna call it like this

giveMeHeader("c:\folder\mytextfile.txt")

or

giveMeHeader("c:\folder\song.mp3")

and that returns me full header information and data context, both as string.


Then I want to store two information on DB or somewhere else to create files whenever i want with header and context info.


How can i do this from the easiest way?


Thanks a lot in advance,

codepenman
Newbie Poster
7 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

HEADER Header;

void ReadHeader(FILE *fp)
{
if (fp != (FILE *)NULL)
{
fread(&Header.Id, sizeof(Header.Id), 1, fp);
fread(&Header.Height, sizeof(Header.Height), 1, fp);
fread(&Header.Width, sizeof(Header.Width), 1, fp);
fread(&Header.Colors, sizeof(Header.Colors), 1, fp);
}
}

arjun.yegneswar
Newbie Poster
2 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

thank u arjun but i couldnt get a point

is FILE filepath as string?

and what type does this function returns?


and this contains "Header.Colors" so if any file i try to get header of, becomes a txt file or mp3, will that make a problem because i cant mention about a color in sound file. im confused a little..

codepenman
Newbie Poster
7 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

isnt there anybody else who can guide me somehow please??

codepenman
Newbie Poster
7 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

You don't need header files in C#. Just put each class definition in its own file. The compiler knows where to find them. The only thing to watch out for is namespaces. If two classes are in different namespaces, then you'll have to include a "using" statement to import the namespace the other class is in.

arjun.yegneswar
Newbie Poster
2 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

no no i have been misunderstood.

All i want to be able to embed a music or image file into database.
Shouldnt' I get the "header of image/media file" for that operation?

Best Regards,

codepenman
Newbie Poster
7 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: