AX 2012: Moving File to another Folder using System.IO.File

static void ArisMoveFileUsingSystemIOFile(Args _args)
{
#File
Set permissionSet;
Filename fPath;
Filename fName;
Filename fType;

Filename sourcePath = @’D:\SourceFolder\test.csv’;
FileName DestinationPath = @’D:\DestinationFolder\’;

#define.sourcePath(sourcePath);
#define.destinationPath(DestinationPath)

permissionSet = new Set(Types::Class);
permissionSet.add(new FileIOPermission(sourcePath,#io_write));
permissionSet.add(new InteropPermission(InteropKind::ClrInterop));

CodeAccessPermission::assertMultiple(permissionSet);

[fPath, fName, fType] = fileNameSplit(sourcePath);

System.IO.File::Move(sourcePath, strFmt(‘%1%2%3’, #destinationPath, fName, fType));

CodeAccessPermission::revertAssert();

Box::info(‘File\s moved successfully!’);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s