Notifications
Announcements
No record found.
I am referring this code
community.dynamics.com/.../ax-2012-reading-files-from-directory-through-x
The code that you refer to reads all lines starting from the first line (while this.readLine()).
So all you need to do is to not call processRow in the first iteration of that while loop for each file.
another thing you can make code to start reading from row 2 instead of 1. I can understand you have headers on top row of the file.
I tried many ways but it still copy the header for next file.
i tried but nothing happened
We could try to spot what's wrong with your code, but you forgot to share it..
Anyway, let's take the code from the blog and demostrate. I added new variable currentRowInFile to handle the requirement of skipping the first row of each file:
private void readFilesFromDirtecory() { SetEnumerator sE; int row = 1; filePath = @"C:\Temp\FilesToRead"; this.getFiles(); sE = fileSet.getEnumerator(); while (sE.moveNext()) // loop through all files { int currentRowInFile = 1; filename = sE.current(); this.openFile(); while(this.readLine()) // loop through all lines from current file { if (currentRowInFile > 1) { this.processRow(row, lineCon); } currentRowInFile ; row ; } } }
Is it now clear? If not, please share your code so that we can help with it.
Hi Marian,
What exact product are you using? You shared a blog related to AX2012, but posted the question in the Dynamics 365 forum.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 559 Most Valuable Professional
André Arnaud de Cal... 464 Super User 2025 Season 2
Sohaib Cheema 250 User Group Leader