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, ...
Answered

TextIO Class Initialization Issue

(1) ShareShare
ReportReport
Posted on by 124
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;
    #File
    ;

    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)
}
 
I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,987 Most Valuable Professional on at
    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.
  • Anton Venter Profile Picture
    20,346 Super User 2025 Season 2 on at
    Why not change your code to use the .NET MemoryStream class? Then you don't have to write anything to a physical file.
  • D365_FO_Technical_Te Profile Picture
    124 on at
    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.

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans