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

Announcements

News and Announcements icon
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 126
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
    240,540 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
    21,175 Super User 2026 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
    126 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 345 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 304

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans