Thursday, January 12, 2017

X++ code to Move file from one folder to another folder in Ax 2012

Hi Reader's,

Here the post to move files from one folder to another folder in ax 2012.


static void MoveFilesFromFoldertoAnotherFolder(Args _args)
{
 FilenameOpen fileNameOpen;
 DialogField dialogFileName;
 Dialog dialog;
 Filename filePath;
 Filename fileName;
 Filename fileType;
 FileName DestinationPath;
 #File

 ;
DestinationPath = @'C:\Users\shiva.p\Desktop\Dest\'; // Define your Destination Path
 dialog = new Dialog("Move Files");

 dialogFilename = dialog.addField(extendedTypeStr(FileNameOpen));

dialog.filenameLookupFilter([#AllFilesType]);
 dialog.filenameLookupTitle("Select File");
 dialog.caption("Move File");
 dialogFilename.value(fileName);
if(!dialog.run())
 return;
filenameOpen = dialogFilename.value();
 [filePath, fileName, fileType] = fileNameSplit(fileNameOpen);
// MoveFile - The Original File won't be available once it's moved into destination path
WinAPI::moveFile(fileNameOpen, DestinationPath+FileName+FileType);
// CopyFile - The Original File will be available even if it's moved into destination path
 //WinAPI::copyFile(fileNameOpen, DestinationPath+FileName+FileType);
// DeleteFile - Delete the Selected File
 //WinAPI::deleteFile(fileNameOpen);

 // If u need to Use this in Form Take look in AOT > Forms > Tutorial_Form_File
}


No comments:

Post a Comment

Export a copy of the standard user acceptance testing (UAT) database

 Reference link: Export a copy of the standard user acceptance testing (UAT) database - Finance & Operations | Dynamics 365 | Microsoft ...