Reputation: 1800
I'm making a filestream
to read from a text file, I want to make sure that user specified destination really is a text file and not a picture or something else
Upvotes: 0
Views: 97
Reputation: 7773
You cannot make sure the file is a text file. As pointed by Kiyura, it is impossible to be a 100% sure that a file is text or binary unless you have strict assumptions about the file, like the language used and the encoding.
Knowing both of these, you could do some statistical analysis of the content to make sure if the words contained in the file make sense overall.
Upvotes: 1