Transfer file one folder to another folder in Ax 2012

Description:-

In this article we will about how to move a File from One Folder to another folder using X++. use below code to move file from one folder to another folder using System.IO.File.

#File
Set permissionSet;
Filename sourcePath,DestinationPath;
Filename fPath;
Filename fName;
Filename fType;
str      path;

sourcePath = @'Filepath + Filename + file extension';
if(System.IO.File::Exists(sourcePath))
{   
  DestinationPath = @'DestinationFolderPath';
  #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);
  // MoveFile - The Original File won't be available once it's moved into destination path
  System.IO.File::Move(sourcePath, strFmt('%1%2%3', #destinationPath, fName, fType));
  CodeAccessPermission::revertAssert();
}

Related Posts

Thanks for comments.....

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer