Detecting if a file is binary or plain text?

Posted by dr. evil on Stack Overflow See other posts from Stack Overflow or by dr. evil
Published on 2010-05-27T17:15:54Z Indexed on 2010/05/27 17:21 UTC
Read the original article Hit count: 154

Filed under:
|
|
|

How can I detect if a file is binary or a plain text?

Basically my .NET app is processing batch files and extracting data however I don't want to process binary files.

As a solution I'm thinking about analysing first X bytes of the file and if there are more unprintable characters than printable characters it should be binary.

Is this the right way to do it? Is there nay better implementation for this task?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about file