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:
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;
And then for the GetImageText function:
private string GetImageText(string path)
{
byte[] imageByte = System.IO.File.ReadAllBytes(path);
string convertedString = Convert.ToBase64String(imageByte);
return convertedString;
}
No error occurs, however the label does not show the text, so I assume theres a problem with my encoding process.