c# 写一个将指定路径的pdf转换为base64字符串的方法
以下是一个将指定路径的PDF转换为Base64字符串的C#方法:
public static string ConvertPdfToBase64String(string filePath)
{
byte[] fileBytes = File.ReadAllBytes(filePath);
return Convert.ToBase64String(fileBytes);
}
该方法使用File.ReadAllBytes方法将文件读入字节数组中,然后使用Convert.ToBase64String方法将字节数组转换为Base64字符串。只需将PDF文件的路径作为参数传递给该方法即可。
原文地址: https://www.cveoy.top/t/topic/fHSL 著作权归作者所有。请勿转载和采集!