简体   繁体   中英

object variable with rtf data and preceding System.Byte[] characters

My dll written in C# works with C++ program via com. I get from that program stream of bytes which are supposed to be an rtf data (and they are), and when I tried to assign it to rtf control, I got an ArgumentException. When I saved that stream to a file to see ansi characters, I noticed that first bytes of that stream begins with "System.Byte[]":

System.Byte[]{\rtf1\ansi\ansicpg1250\deff0\deflang1045{\fonttbl{\f0\fnil\fcharset238{\*\fname Courier New;}Courier New CE;}{\f1\fnil\fcharset238 Microsoft Sans Serif;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\f0\fs16 aa\cf0\f1\fs17\par
}

Simple conversion to byte[] doesn't work and actually I don't know how to get rid of it. I'm not much experienced, but it seems to be sort of serialization information. I tried to use BinaryFormatter as well, but without a success.

Any idea where it comes from and how to work it out?

Thanks, Ray

Can't you just remove the string "System.Byte[]"? I've never used rtf before but I saved your output in a file (without "System.Byte[]" of course) and word opened it without any problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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