Skip to main content



No record found.

Dynamics 365 Community / Forums / Finance forum / TextIO Class Initializ...
Finance forum

TextIO Class Initialization Issue

Posted on by 112
Hello everyone,
I am using TextIO Class in my code, but when i am debugging it - on initializing the class i am getting Null Value. can anyone please help me how can i initialize it. I am using below code. I have used same piece of code on AX , there it's working fine. But on D365 I am facing issue.
FilePath    _filePath;   //_filePath is my Global Variable

Public void ABC()
    TextIo    textIo;
    FileName  fileName;
    str       getFileName_Path;

    fileName = strfmt("barcode_%1.prn", curUserId());
    _filePath = InventParameter::find().FilePath;
    getFileName_Path =   _filePath +  fileName;
    //I have used both below code, but still i am receiving null value in debugger.
    //textIo = new TextIO(getFileName_Path, #IO_Write, 65001)
      textIo = new TextIO(getFileName_Path, #IO_Write)
  • TextIO Class Initialization Issue
    Thanks Anton & Martin for your response.
    You were right Martin, it was a permission issue. I changed the path which was writable, and its started working.
  • Anton Venter Profile Picture
    Anton Venter 9,453 Super User on at
    TextIO Class Initialization Issue
    Why not change your code to use the .NET MemoryStream class? Then you don't have to write anything to a physical file.
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 225,526 Super User on at
    TextIO Class Initialization Issue
    First of all, are you sure you need to create a file on the given AOS at all? Don't you want to use TextStreamIo, for example, instead?
    If you have to, make sure that the location exists and it's writable. Letting users to configure the path doesn't make a good sense to me - I recommend simply using the Temp folder (e.g. WinApiServer::getTempPath()). The fact that you want to configure it suggests that you want to use as a data storage, which would be a bug in the design. There is more than one AOS and they can be added or deleted as needed.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,835 Super User

Martin Dráb Profile Picture

Martin Dráb 225,526 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans