Probably the easiest way is to use the C Run Time function, isprint. That will determine if a byte is a printable character. As you scoot through the file, as soon as you find a byte that's not printable, you can probably safely assume it's not a text file. Of course, if you want to allow UNICODE text files, you'll have to do much more work, which is not fool proof.
Dig deeper on Windows Operating System Management
Related Q&A from John Robbins
What is a JAD session? This term is referred to often in job postings and seems like some kind of brainstorm you carry out with a client to define IT...continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.