Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining The Right file Type 3

Status
Not open for further replies.

jbl1167

Programmer
Oct 2, 2006
78
US
I need to determine the file type of thousands of files. Some have extension, others not. Some may even have the wrong extension. What is the best way to determine the real file type? Do exist tools that I can add to my program or utlities that may assist me on this task?

Thank you
 
Hi, to be honest I've never attempted this in .net but in old school vb you could open the file as binary and do a quick read of the header information.

e.g.

"MZ" is an exe
"ID3" is an mp3

and so on...

Sorry, probably of no use but hopefully gets you thinking!

Nick
 
Try looking into the FileVersionInfo Members

I'm not 100% sure on missing extensions though and its reaction to grabbing the gettype

____________ signature below ______________
You are a amateur developer until you realize all your code sucks.
Jeff Atwood

 
Nickdel,

Thank you. Do you know where I can get a dictionary table or something to indicate me the different file types on the techique that you described?

Thank you
 
erm.. not off the top of my head but there is bound to be one out there! Try searching for file signature match or file hexidecimal signature (which will differ from my example above but still available within the file header e.g. "424D" is for a bitmap file (.bmp), normally contained within the first 20 characters of the header)

Cheers

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top