title: Detect if file contains text
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/910873/how-can-i-determine-if-a-file-is-binary-or-text-in-c">How can I determine if a file is binary or text in c#?</a><br>
    <a href="https://stackoverflow.com/questions/4744890/c-sharp-check-if-file-is-text-based">C# - Check if File is Text Based</a>  </p>
  </blockquote>
  
  
  
  <p>To better understand multi threading and asynchronous tasks, I wrote a simple application in C# to count the total number of lines of code in a project (directory).</p>
  
  <p>Currently, I open a file and count the number of lines in each file. However, that includes all files (jpg, png, exe etc.). Is there a way I can detect if a file is a text file? Possibly by detecting ASCII Encoding or something similar.</p>