Reputation: 111
I am working on a system that saves temporary files in windows\temp. These files take on a .tmp file extension.
I am working on functionality that needs to read one of these files, identify whether it is an image or video file, and the filetype. Since the files are saved as .tmp, I can not use the file extension.
I've already written code that identifies whether the file is a valid image file, and it's filetype - This was actually quite easy, to my surprise!
My question is this: How can I identify whether an array of bytes is a valid video file, and if it is, how can I identify it's filetype?
Upvotes: 0
Views: 2150
Reputation: 3710
As I understand, this is in general not an easy task as there are hundreds of formats. But I guess if you learn about binary signatures, or file signatures, you'll get a step forward with this question.
Here is an idea: http://www.den4b.com/wiki/ReNamer:Binary_Signatures
And here more information: http://en.wikipedia.org/wiki/List_of_file_signatures
Good luck :-)
Upvotes: 3