Within a C# program, is there any way to tell if a file is a text file or not? I mean a real way, not just basing your conclusion on a file name extension.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jan MontanoPosted Jan 29, 2009, 12:17 AM
First we must define what you mean by a text file. In my definition, it's a file that contains data which is readable. It may contain japanese characters, chinese characters, english characters etc. The content is not garbled. When I open the text file, it may have garbled korean data if I have no korean language pack installed in my machine. So to be sure, I must install all language packs.
via code... I think it can't be done easily. If it's just english characters we're talking about, we just have to parse the file and check each character if it corresponds to the ascii characters. But when we're talking about different languages, that's a different story.
Just my two cents.