title: Converting .dat File to Image File in C#
body: <p>I'm trying to get windows user profile picture from <code>C:\ProgramData\Microsoft\User Account Pictures\{UserName}.dat</code> by this code:</p>
  <pre class="lang-cs prettyprint-override"><code>public static Image GetUserimage()
  {
      if (File.Exists(@&quot;C:\ProgramData\Microsoft\User Account Pictures\&quot; + Environment.UserName + &quot;.dat&quot;))
      {
          return Image.FromFile(@&quot;C:\ProgramData\Microsoft\User Account Pictures\&quot; + Environment.UserName + &quot;.dat&quot;);
      }
      else
      {
          return Cheat.Properties.Resource1.Image1;
      }
  }
  </code></pre>
  <p>But I get this error when trying to call it <code>pictureBox1.Image = GetUserimage();</code>:</p>
  <blockquote>
  <pre><code>System.OutOfMemoryException: 'Out of memory.'
  </code></pre>
  </blockquote>
  <p>And I think the reason is <code>.dat</code> is not image file to use it as image.</p>
  <p><strong>So my question is HOW TO CONVERT .dat FILE TO IMAGE FORMAT TO USE IT AS IMAGE VAR ?</strong></p>