Friday, October 24, 2014

Delete or Copy or Move File through X++ AX 2012

// Delete /Move/ Copy File and Remove Directory

static void deleteMoveCopyFolder(Args _args)
{
    DialogField         dialogFileName;
    FilenameOpen        fileNameOpen;
    Dialog              dialog;
    Filename            filePath;
    Filename            fileName;
    Filename            fileType;
    FileName            DestinationPath;
    dialog              = new Dialog();
    dialogFilename      = dialog.addField(extendedTypeStr(FileNameOpen));
    DestinationPath     = @'E:\Dest\';
    if(dialog.run())
    {
        filenameOpen                   = dialogFilename.value();
        [filePath, fileName, fileType] = fileNameSplit(fileNameOpen);
        WinAPI::moveFile(fileNameOpen, DestinationPath+FileName+FileType);
        WinAPI::copyFile(fileNameOpen, DestinationPath+FileName+FileType);
        WinAPI::deleteFile(fileNameOpen);
    }

}

Another :
System.IO.File::Move("C:\\test.txt", "D:\\test.txt");

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...