Monday, January 11, 2016

AX 2012: File existance check

Multiple ways to check file existance in AX 2012;

Client side check, does not work with batch job

WinAPI::fileExists(_fileName);

Server side check which works for run base batch too

public boolean getFileExists(filepath _fileName)
{
   System.IO.FileInfo   fileInfo;
   new InteropPermission(InteropKind::ClrInterop).assert();
   fileInfo = new System.IO.FileInfo(_fileName);
   return fileInfo.get_Exists();

}