class Program
{
static void Main(string[] args)
{
string base64 = getFileBase64("D:\\Users\\VatInvoiceOCR1.jpg");
byte[] file = Convert.FromBase64String(base64);
Console.WriteLine($"图片的base64编码:{base64}");
Console.WriteLine($"图片的二进制数据:{file}");
Console.ReadKey();
}
public static string getFileBase64(String fileName)
{
FileStream filestream = new FileStream(fileName, FileMode.Open);
byte[] arr = new byte[filestream.Length];
filestream.Read(arr, 0, (int)filestream.Length);
string baser64 = Convert.ToBase64String(arr);
filestream.Close();
return baser64;
}
}