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

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...