Announcements
Hi,
I want to access a file which is located on Desktop using x++ for Reading.
I have a text file as an input, let say, 'input.txt', I need to concatenate filepath with input.txt. I have used filepath = @"C:\Users\Dinesh\desktop\",
& did this filepath + fileName = @"C:\Users\desktop\input.txt" but this is not working.
Also I have used System.IO.Path::getFullPath('input.txt'), but this returned the wrong path.
Is their any other way to get the file path using x++ ?
Thanks & Regards,
Dinesh
Hi Martin,
Thanks for the quick reply.
As you Suggest I have created a file upload option & now I am able to Upload file & can process data in it.
Thanks & Regards,
Dinesh
Moved from Dynamics AX forum.
X++ runs on a web server in an Azure data center; it can't connect to users machines machines and manipulate their files. Therefore the your design is fundamentally wrong.
What you can do is giving users an option to upload a file that you'll then process in your class.
Hi Komi,
I have used as you suggest but the file is not opening using this fullpath which got through strfmt.
Thanks & Regards
Dinesh
Hi Martin,
Thanks for the Suggestion.
I am using the current version of D365 finance & operations.
Actually, I am working on SysOperationFramework, I want to access a file located on my desktop & will do something with the data of the file.
I am passing FileName as parameter in Contract class & then in Service class I will concatenate filePath & fileName to get the full path of the file & can access it.
On my system Desktop path is : @"C:\Users\Dinesh\desktop\" I have used it but was not able to access that file.
I am using StreamReader class to open the file for reading : System.IO.StreamReader streamReader = new System.IO.StreamReader(sTempPath + sFileName);
Before that I have used this : System.IO.Path::GetTempPath(); to access the Temp folder on windows & with this I have read the file located in windows temp folder & access the data, it was working fine but when I did this same task in Batch using SysFramework that time I got the wrong path of temp folder.
So, I want to access the file path that must work same in Synchronous & in batch process as well.
Thanks & Regards,
Dinesh
Please never describe a problem by mere "it's not working", because there is no universal solution for all possible problems. Describe your particular issue.
Also, what version of AX is it about?
You can use the StrFmt:
str FileToAccess = strFmt("%1%2",filepath,fileName)
André Arnaud de Cal...
293,296
Super User 2025 Season 1
Martin Dráb
232,093
Most Valuable Professional
nmaenpaa
101,156
Moderator