I am fetching messages from an IBM MQ using .Net C# IBM.XMS library. I can receive the messages (IMessage) and I am able to get the message and save the file when its sent as text. I use the .Text property. However I don't know how to save get the message if its sent in say zip. I try to see if I can get the byte[] body and save it as a file. Any suggestions on how to do it?
message = consumer.Receive(TIMEOUTTIME);
if (message != null)
{
_log.LogInformation("Message received.");
var fileName = _fileUtil.GenerateFileName(_queueName);
int receivedBytes = 0;
if (message is ITextMessage)
{
var msg = (ITextMessage)message;
var result = msg.Text;
}
else if (message is IBytesMessage)
{
var msg = (IBytesMessage)message;
byte[] result = msg...
(how to get the bodys byte array)
...
File.WriteAllBytes(filepath, result);
}