Monday, 6 October 2025

Convert String to System.IO.Stream

 str string  = 'some string';

// Convert String to System.IO.Stream
System.Byte[]           byteArray   = System.Text.Encoding::get_UTF8().GetBytes(string);
//System.Byte[]           byteArray   = System.Text.Encoding::get_ASCII().GetBytes(string);
System.IO.MemoryStream  stream      = new System.IO.MemoryStream(byteArray);
 
// Convert Byte array to String
string = System.Text.Encoding::get_UTF8().GetString(byteArray);
//string = System.Text.Encoding::get_ASCII().GetString(byteArray);

No comments:

Post a Comment

Setting VendInvoiceInfoTable default values for custom fields - D365 FO

  When creating a vendor invoice and you are trying to populate custom fields on table VendInvoiceInfoTable you may find that the following ...