[IronPython] How to convert a 'str' type to byteArray

matan keret matan504 at gmail.com
Wed Nov 11 16:14:29 CET 2009


I have the following code which gets an image from an email.
after getting it i need to pass it as a byteArray (byte[] in C#) to a C#
i tried all sorts of things but no luck. I'm using ironPython 2.0.3

the important parts of the code are:

# getting the image from the e-mail
image = part.get_payload()

# my try to cast the str into a byteArray
byteArray = BitConverter.GetBytes(image.ToCharArray())

this last line returns 1 byte and doesn't seem to do the job.
is there any equivalent to the 'bytearray(image)' function in CPython?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20091111/c32e3208/attachment.html>

More information about the Ironpython-users mailing list