0

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.

6
Contributors
10
Replies
11
Views
9 Years
Discussion Span
Last Post by Ramy Mahrous
0

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.

0

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

But using "*.txt" will work fine ?

0

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

0

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

0

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 ..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.