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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Simple: Convert Text to Instream

(1) ShareShare
ReportReport
Posted on by 42

Is there a simple and nice way to convert a Text variable to an Instream?

I just want to enable the user to download a file, whose content I already store using a Text var.

My dirty way works as following, but the Record TempBlob is marked for removal:

var
    fileName: Text;
    fileContent: Text;
    istream: InStream;
    oStream: OutStream;
    tempBlob: Record TempBlob temporary;
begin
    // Here some code to fill fileContent and fileName
    tempBlob.WriteAsText(fileContent, TextEncoding::UTF8);
    tempBlob.Blob.CreateInStream(istream, TextEncoding::UTF8);
    DownloadFromStream(istream, 'Export', '', 'All Files (*.*)|*.*', file_name);
end;

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,208 Super User 2026 Season 1 on at

    Please try function FromBase64 in codeunit 4110 "Base64 Convert"

  • Verified answer
    Binesh Profile Picture
    7,887 on at

    Hello,

    Go for  Mohana Yadav suggestions you will get some idea.

    Or else by little bit changes on your code will work as shown below.

    procedure DownloadTextToStream()
        var
            fileName: Text;
            fileContent: Text;
            istream: InStream;
            oStream: OutStream;
            tempBlob: Codeunit "Temp Blob";
        begin
            // Here some code to fill fileContent and fileName
            Clear(tempBlob);
            tempBlob.CreateOutStream(oStream, TEXTENCODING::UTF8);
            oStream.WriteText(fileContent);
            tempBlob.CreateInStream(istream);
            DownloadFromStream(istream, 'Export', '', 'All Files (*.*)|*.*', fileName);
        end;

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,024 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,145 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 705 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans