如何将byte []转换为base64Binary(不是base64String)?

编程入门 行业动态 更新时间:2024-10-26 02:25:11
本文介绍了如何将byte []转换为base64Binary(不是base64String)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

SQL Server表列类型为Image。

The SQL server table column type is Image.

C#代码将文件(例如.docx)转换为byte []。 byte []可以插入SQL中的Image列。但客户端需要base64Binary转换回文件。他们收到错误"i s 不是"base64Binary "的有效值和" Base-64字符数组的长度无效 " ;.如何将byte []转换为 base64Binary?

The C# code converts a file (e.g. .docx) to byte[]. The byte[] can be insert into the the Image column in SQL. But the client required base64Binary to convert back to a file. They received an error "is not a valid value for 'base64Binary" and "Invalid length for a Base-64 char array". How can I convert the byte[] tobase64Binary?

我试过base64String。我得到"nvarchar与图像不兼容"。我谷歌但它似乎只找到转换为base64String。

I tried base64String. I got "nvarchar is incompatible with image". I google it but it seems only finding convert to base64String.

谢谢。

推荐答案

我认为你应该使用 Convert.ToBase64String 而不是将数据插入数据库,而是在将字符串发送到客户端之前将提取的字节转换为base-64字符串。客户将使用 Convert.From64String 。

I think that you should use Convert.ToBase64String not for inserting the data to database, but for converting the extracted bytes to base-64 string before sending the string to Clients. The Clients will use Convert.From64String.

显示有关数据和错误的详细信息。哪些字符串发送给客户?

更多推荐

如何将byte []转换为base64Binary(不是base64String)?

本文发布于:2023-11-26 19:33:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634909.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   如何将   base64String   byte   base64Binary

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!