title: How Do I Convert An Image To Base64 String?
body: <p>I have a form that pops up a file browser and upon selection should get the pathway of the selected file and then convert that image into a string. I have this code:</p>
  
  <pre><code>string sfn = "";
  OpenFileDialog ofD = new OpenFileDialog();
  if (ofD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  {
      sfn = ofD.FileName;
  }
  
  string imagePathway = sfn;
  string imageToText = GetImageText(imagePathway);
  label1.Text = imageToText;
  </code></pre>
  
  <p>And then for the GetImageText function:</p>
  
  <pre><code>private string GetImageText(string path)
  {
      byte[] imageByte = System.IO.File.ReadAllBytes(path);
      string convertedString = Convert.ToBase64String(imageByte);
      return convertedString;
  }
  </code></pre>
  
  <p>No error occurs, however the label does not show the text, so I assume theres a problem with my encoding process.</p>