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.

You can look inside the file and see what's there. If it conforms to your expectations -- if the file or the first 1000 bytes of the file contains only characters that conform to one of some particular set of character encodings, maybe you have a text file.

Rashakil Fol gave the only thing else i could think of ...

But using "*.txt" will work fine ?

Sure, but its not a guarentee doesnt stop people adding a .txt extension to anything

text file means .txt or contains text data like .rtf, or .txt?

Any file extension (or even lack of) could be text inside it.. similarly just as I said, just because it got named .txt doesnt make it text

And they can predict the content of file (Text or binary) that's why I asked!

Adobe acrobat reader documents although binary often start with the text %PDF

If you look Danny to the end of pdf files you'll find too a lot of special characters...

A lot of files start with a specific signature, zip files etc.. However, this isnt answering his quesiton.. mind you, nor is he we've just done a lot of speculation ..

Is it the end of the world? we gave a lot of solutions not speculations!!, and if I were he, I used some of.