Thursday 23 February 2012

Copying a file from one location to other location using X++

Copying a file using WINAPI Classes in AX2009

static void WinApiClassestocopythefile(Args _args)
{
#avifiles
boolean                             present;
SysOperationProgress    simpleProgress;
int i;
;
// startlengthyoperation();
SimpleProgress = SysOperationProgress::newGeneral(#aviupdate, 'Simple', 100);
if(WinAPI::fileExists("C:\\Documents and Settings\\AxUser\\MyDocuments   \\Downloads\\ganatharva.pdf"))
{
for (i=1; i<=100; i++)
{
simpleProgress.incCount();
simpleprogress.setText(strfmt("%1% Of File is being Copied",i));
sleep(200);
}
WinAPI::copyFile("C:\\Documents and Settings\\AxUser\\My Documents\\Downloads\\ganatharva.pdf","C:\\Documents and Settings\\AxUser\\My Documents\\Morphx\\ganatharva.pdf",true);
Simpleprogress.kill();
}
else
{
info("This file does not exist");
}
info("The file has been Copied :)");
info(strfmt("The filesize is %1",WinApi::fileSize("C:\\Documents and Settings\\AxUser\\My Documents\\Morphx\\ganatharva.pdf")));
info(WinAPI::getComputerName());
}

1 comment: