Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C将html文件中的图像转换为base64#_C#_Html_Image_Base64 - Fatal编程技术网

C# 使用C将html文件中的图像转换为base64#

C# 使用C将html文件中的图像转换为base64#,c#,html,image,base64,C#,Html,Image,Base64,我有一个html文件,我想用C#将它的图像从本地源转换成base64 如果您能帮助我,我们将不胜感激。读取文件的字节,然后将其转换为base64: byte[] imageArray = System.IO.File.ReadAllBytes(@"image path"); string base64 = Convert.ToBase64String(imageArray); 如果文件不是本地文件,您需要。这有帮助吗?当我创建base64字符串时,我应该将其替换为图像路径?如何在html

我有一个html文件,我想用C#将它的图像从本地源转换成base64



如果您能帮助我,我们将不胜感激。

读取文件的字节,然后将其转换为base64:

byte[] imageArray =  System.IO.File.ReadAllBytes(@"image path");
string base64 = Convert.ToBase64String(imageArray);

如果文件不是本地文件,您需要。

这有帮助吗?当我创建base64字符串时,我应该将其替换为图像路径?如何在html文件中找到图像路径?@请问另一个问题。
byte[] imageArray =  System.IO.File.ReadAllBytes(@"image path");
string base64 = Convert.ToBase64String(imageArray);