将图像/二进制数据转换为可读 [英] convert image/binary data to readable
本文介绍了将图像/二进制数据转换为可读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法通过使用以下代码将2种类型的数据转换为可读记录。这些数据通过使用LEI从lotus note迁移到sql server。
任何人都知道怎么做?
Hi,
I failed to convert following 2 type of data into readable record by using following code. This data migrated from lotus note to sql server by using LEI.
Anyone know how?
in image data type:
0x82FF520001000000000000000000AF05002DAF0500000000000000000000000000000000000000000000000000000000000000000000000000000000000086010000000054040F0000000F000000000000008304010085FF08000500000881028304010085FF3B000500000820202020202020202020202020202020202020
in binary data type:
0x82FF520002000000000001000000AF052337AF0500000000000000000000000000000000000000000000000000000000000000000000000000000000000086010000000054040F0000000F000000000000008304020085FF08000600000900000000000000000000000000000000000000000000000000000000000000000000
<无线电通信/>
string sqlText = "..."
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ToString());
SqlCommand command = new SqlCommand(sqlText, connection);
//open the database and get a datareader
connection.Open();
SqlDataReader dr = command.ExecuteReader();
if ( dr.Read()) //yup we found our image
{
const int CHUNK_SIZE = 2 * 1024;
byte[] buffer = new byte[CHUNK_SIZE];
long bytesRead;
long fieldOffset = 0;
using (var stream = new MemoryStream())
{
while ((bytesRead = dr.GetBytes(dr.GetOrdinal("checklist"), fieldOffset, buffer, 0, buffer.Length)) > 0)
// while ((bytesRead = dr.GetBytes(dr.GetOrdinal("CCList"), fieldOffset, buffer, 0, buffer.Length)) > 0)
{
stream.Write(buffer, 0, (int)bytesRead);
fieldOffset += bytesRead;
}
Response.BinaryWrite(stream.ToArray());
}
推荐答案
我想将上述数据转换为可读文本。那些数据已存在于我的数据库中。
上面的代码不起作用。请帮忙!
I would like to convert the above data to readable text. Those data already in my database.
Above code did not work. Please help!
你到底想做什么?
我想你想把图像保存到数据库然后检索它?
导入:加载你的图像,然后将其转换为字节数组,然后你可以将它添加到你的数据库..
orm你可以转换字节数组是否为base64-string?
what exactly do you want to do?
I think you want to save a image to a database and then retrieve it?
import: load your image, then convert it to a byte-array and then you can add it into your db..
orm you can convert the byte array into a base64-string?
这篇关于将图像/二进制数据转换为可读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文