How can detect filetype for files without extension?

This is a discussion on How can detect filetype for files without extension? within the C Programming forums, part of the General Programming Boards category; Hi, Is it possible to find out type of a file that don't have extension, for example exe, doc, pdf ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    1

    How can detect filetype for files without extension?

    Hi,

    Is it possible to find out type of a file that don't have extension, for example exe, doc, pdf ,...?
    Does type of a file keep any other place, for example in header of file?
    If no, how can detect type of a file?

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    3,831
    `libmagic'

    Soma

  3. #3
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    On Windows you'd have to do a great deal of analysis of the file data. If you were only looking for two or three types then it might be possible, but if you wanted something generic to find the any filetype without the extension, it'd be incredibly difficult.

    Some files have certain headers and magic numbers at the beginning of them. For example, all executable files on Windows contain the two letters "MZ" at the beginning of the file. Other files might start like this but there are other factors.

    It really depends on what file formats you want to find, some have lots of information you can identify them by, others don't. You should open up some files of the same type in a hex editor to try and see some of the similarities (will be difficult without information of the headers).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create Copies of Files
    By Kanshu in forum C++ Programming
    Replies: 13
    Last Post: 05-09-2009, 07:53 AM
  2. Language extension
    By Prelude in forum Contests Board
    Replies: 48
    Last Post: 06-25-2004, 06:21 AM
  3. Replies: 5
    Last Post: 11-20-2003, 12:27 AM
  4. get file extension
    By Nada in forum C Programming
    Replies: 3
    Last Post: 12-22-2001, 08:12 AM
  5. sprintf, extension of files??
    By Gades in forum C Programming
    Replies: 10
    Last Post: 11-17-2001, 10:29 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21