0

is there a way i can look at a file and see its type. i need to make a program that scans files and determins if the file extenstion is correct based on the actual file type.
this, for example, would find a ".zip" file hidden with a ".jpg" extension
any ideas?

2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by campkev
0

i don't think so, at least not easily. all files are basically just a long string of bytes. The extension tells windows (or whatever OS you are using) what to do with that string. By changing the extension, say from .jpg to .txt, you are, in essence, making that jpg into a text file. Now certain extensions are expected to have certain formats and probably will not work properly if you change the extension. But other than doing a bytewise scan looking for certain patterns, which would be beyond my skill level, I don't think there is a way to do what you want. Any more experienced programmers have any ideas? Or am I completely full of you know what here?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.