You obviously would have to check the actual content of the file. See if this
Link[
^] helps.
Every format has a unique byte layout that should tell them apart even if you rename the extension.
[EDIT:] obviously a real text file is just going to be plain text so no format layout as such