将不可序列化的对象转换为字节数组 [英] Converting an unserializeable object to a byte array

查看:124
本文介绍了将不可序列化的对象转换为字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




任何人都可以告诉我如何将一个不可序列化的对象转换为一个

System.Web.Mail.MailMessage对象字节数组,然后将

字节数组转换为Base64字符串?


感激不尽的任何帮助。


此致,


Mark Rae

Hi,

Can anyone please tell me how to convert an unserializeable object say, a
System.Web.Mail.MailMessage object, to a byte array and then convert the
byte array to a Base64 string?

Any assistance gratefully received.

Best regards,

Mark Rae

推荐答案

Mark Rae写道:
Mark Rae wrote:


任何人都可以告诉我如何将一个不可序列化的对象,比如一个System.Web.Mail.MailMessage对象转换为字节数组,然后转换字节数组为Base64字符串?

感谢所有的帮助。

致以最诚挚的问候,

Mark Rae
Hi,

Can anyone please tell me how to convert an unserializeable object
say, a System.Web.Mail.MailMessage object, to a byte array and then
convert the byte array to a Base64 string?

Any assistance gratefully received.

Best regards,

Mark Rae




Mark,


我将从属性中手动构建一个字节数组和

System.Text.Encoding.ASCII.GetBytes() (或unicode),然后你可以使用Convert.ToBase64String()将它转换为Base64到Base64。 />

- Pete



Mark,

I would manually build a byte array from the properties and
System.Text.Encoding.ASCII.GetBytes() (or unicode), then you can convert it
to Base64 with Convert.ToBase64String().

- Pete


" AirPete" < x@x.x>在消息中写道

新闻:%Q ****************** @ newsread2.news.pas.earth link.net ...


Pete,


感谢您的回复。
"AirPete" <x@x.x> wrote in message
news:%Q******************@newsread2.news.pas.earth link.net...

Pete,

Thanks for the reply.
我会从属性中手动构建一个字节数组和
System.Text.Encoding.ASCII.GetBytes()(或unicode)
I would manually build a byte array from the properties and
System.Text.Encoding.ASCII.GetBytes() (or unicode)




我明显在这里遗漏了什么......你在暗示吗?类似

以下内容:


MailMessage objMailMessage = new MailMessage();

byte [] = System.Text.ASCII .Encoding.GetBytes(objMailMessage);


因为,据我所知,System.Text.Encoding.ASCII.GetBytes()有5

重载,所有这些都将字符串作为它们的第一个(或唯一的)参数。

我正试图在MailMessage对象上找到一种方法,这是

unserializeable。


道歉,如果这不是你的意思,但目前,我不能得到你的

sugge工作。


Best,


Mark



I''m obviously missing something here...are you suggesting something like the
following:

MailMessage objMailMessage = new MailMessage();
byte[] = System.Text.ASCII.Encoding.GetBytes(objMailMessage );

Because, as far as I can see, System.Text.Encoding.ASCII.GetBytes() has 5
overloads, all of which take a string as their first (or only) parameter.
I''m trying to find a way to do this on a MailMessage object, which is
unserializeable.

Apologies if this isn''t what you meant but, for the moment, I can''t get your
suggestion to work.

Best,

Mark


" Mark Rae" ; <毫安** @ markrae.co.uk>在消息中写道

新闻:O8 ************** @ TK2MSFTNGP10.phx.gbl ...
"Mark Rae" <ma**@markrae.co.uk> wrote in message
news:O8**************@TK2MSFTNGP10.phx.gbl...
MailMessage objMailMessage = new MailMessage();
byte [] = System.Text.ASCII.Encoding.GetBytes(objMailMessage);
MailMessage objMailMessage = new MailMessage();
byte[] = System.Text.ASCII.Encoding.GetBytes(objMailMessage );




对于上述内容的抱歉C#... :-)



Apologies for the above being in C#...:-)


这篇关于将不可序列化的对象转换为字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆