Showing posts with label Morph X. Show all posts
Showing posts with label Morph X. Show all posts

Friday, 8 October 2010

Microsoft Dynamics AX 2009 WinAPIServer & WinAPI Class

There are lots of uses for the WinAPI & WinAPIServer classes in Dynamics AX. Two static methods I have found useful recently are;

WinAPIServer::copyFile(...);
WinAPIServer::deleteFile(...);


There isnt a moveFile method however just using the copy then delete method works well. The advantage of these WinAPIServer class methods over the WinAPI class methods are that file permissions are handled by the methods themselves.

Thursday, 7 October 2010

Writing to a CSV in Microsoft Dynamics AX 2009 X++

This post has moved to my new website, if not redirected automaticaly please click here: https://anthonyblake.github.io/ax2009/2010/07/10/ax2009-write-csv.html 

To write to a csv in Microsoft Dynamics AX 2009 X++

//Macros
#File

//File Access Vars
FileIOPermission permission;
CommaTextIO commaio;
FilePath filePath = @'C:\MyFolder\MyOutput.csv';
;

//Set Write Permission For New File
permission = new FileIOPermission(filePath, #io_write);
permission.assert();

//Create CommaIO Object
commaio = new CommaTextIO(filePath, #io_write);

//You Might Want The Next Line To Go In A Loop
commaio.write('Field1', 'Field2', 'Field3', 'etc...etc');

//After Your Loop...
//This Line Isn't Always Needed But Releases
// The Lock On The Output File If It Is To Be Moved
commaio = null;

//Reset Write Access
CodeAccessPermission::revertAssert();