web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

convert Textstreamio container data into system.bytes[] to pass into System.IO.MemoryStream

(2) ShareShare
ReportReport
Posted on by 201
HI,
the issue is the how to convert Textstreamio container data into system.bytes[] to pass into System.IO.MemoryStream.
below is the code I am using.
 
I am running a service class with multi-threading batch task. In each threading, the output is a textstreamio container data.
 
container con = [ field1. field2, .......field10];
textstreamio taskIO = Textstreamio::constructfromwrite(65001); (65001 represents UTF-8 encoding)
taskIO.outfielddelimiter(',');
taskio.writeexp(con);
 
each multi-threading batch task generates around 100,000 records and is saved in a table.
 
BinData data = new Bindata();
container streamContainer = taskio.read();
        
  streamContainer = binData.getData();
  ttsbegin;
  tempcsvfiles.BatchHeaderId = _contract.parmbatchHeaderId();
  tempcsvfiles.TaskNumber = _contract.parmTaskNumber();
  tempcsvfiles.IOStreamData = streamContainer;
  tempcsvfiles.insert();
  ttscommit;
 
to merge all records, 
 
container getfromfile;
Textstreamio textstream;
// Initialize the final stream
textStream = TextStreamIo::constructForWrite(65001);
textStream.outFieldDelimiter(','); 
while select IOStreamData from tempcsvfiles order by tasknumber
{
getfromfile = tempcsvfiles.IOStreamData;
 
//here I have to convert container into system.bytes[] to pass into System.IO.MemoryStream
 
        ??? For D365FO ver 10.0.42 How to write this piece of code  ???
 
 
Categories:
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    You can use Binary class, for example, to convert between create a memory stream from a container and vice versa:
    TextStreamIo taskIO = ...
    
    container con = Binary::constructFromMemoryStream(taskIO.getStream()).content.getContainer();
    
    MemoryStream stream = Binary::constructFromContainer(con).getMemoryStream();

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans