简体   繁体   English

如何将byte []中的HTML保存为图像??? C#

[英]how to save HTML in byte[] as Image??? c#

i have HTML page source of website saved as String in string PageSource; 我将网站的HTML页面源另存为string PageSource; String string PageSource; i need to save it in SQL Database as Image of type image. 我需要将其保存为图像类型为Image的SQL数据库。 How to convert PageSource in byte[] and save it as Image in database. 如何将PageSource转换为byte []并将其另存为Image在数据库中。

You can use the following code to convert a string to a byte array, which can then be saved in a database image field. 您可以使用以下代码将字符串转换为字节数组,然后将其保存在数据库映像字段中。

var bytes = Encoding.Default.GetBytes(htmlString);

Use of image will be deprecated, consider using varbinary(max). 不建议使用图片,请考虑使用varbinary(max)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM