How to read a blob file in text format

Hello guys,

I 'm just facing this problem. I’ve a requirement to read a blob file in text format. Can anyone suggest me on how to achieve this please?

Hi HariKiran
Please refer below code

Variables:-
Name DataType Subtype Length
FileManagement Codeunit File Management
TempBlob Record TempBlob
Encoding DotNet System.Text.Encoding.‘mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’
CellValueText Text
StreamReader DotNet System.IO.StreamReader.‘mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’
Filedata File
CStream InStream
IStream InStream
TempFilePath Text

TempTable.CALCFIELDS(Body);
IF TempTable.Body.HASVALUE THEN
BEGIN
//TempTable.Body.CREATEINSTREAM(IStream);
TempBlob.Blob := TempTable.Body;
TempFilePath := FileManagement.ClientTempFileName(’.txt’);
FileManagement.BLOBExport(TempBlob,TempFilePath,TRUE);
Filedata.OPEN(TempFilePath);
Filedata.CREATEINSTREAM(CStream);
StreamReader := StreamReader.StreamReader(CStream,Encoding.UTF8);
CellValueText := StreamReader.ReadToEnd;
MESSAGE(CellValueText);
END;