There's no reliable way to determine this.
The file could be a UTF-8 Unicode file with a byte-order-mark (three byte flag) at the front of it, and that could cause you to think it's a binary file, when it really is text, just not plain ascii text.
A technique I've seen used is to scan through the first 1000 bytes, counting up printable characters vs. non-printing characters (carriage-returns, etc fall into the non-printing category). You'd then decide on a percentage of non-printing characters to mark your tipping point -- above that quantity, the file is assumed to be binary. Below that amount, you assume it's text.
Chip H.
____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first