title: How to get CMD/console encoding in C#
body: <p>I need to specify the correct codepage to pack the files with zip library. As I see, I need to specify console encoding (866 in my case).</p>
  
  <pre><code> C:\Users\User&gt;mode
  
   Status for device CON:
   ----------------------
       Lines:          300
       Columns:        130
       Keyboard rate:  31
       Keyboard delay: 1
       Code page:      866 &lt;- I need to get this value in C# code
  </code></pre>
  
  <p>Console.OutputEncoding returns 1251, which is not what I need.</p>
  
  <p>Thanks,</p>
  
  <p>Alex</p>
  
  <p><strong>Update 1:</strong> Obviously, execute "mode" in cmd.exe and parse output should work but it seems too rude. I'm looking for .NET solution.</p>
  
  <p><strong>Update 2:</strong> The application is windows forms application, not a console app.</p>