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
I’m making a filestream to read from a text file, I want to make
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.