Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

Unable to move file using System.IO.File

$
0
0

Am trying to move file from one folder to another using System.IO.File. Unfortunately, it does not work, but when I make use of the copy method, the file replicates itself on the specified directory. See code below for your reference. Thanks in advance.

for(rowNo = 1; rowNo <= conLen(pCountFiles) ; rowNo++)
        {
            fileDetails     = fileNameSplit(conPeek(pCountFiles, rowNo));
            pCountFileName  = conPeek(fileDetails, 2);
            newMoveFileDir  =   strFmt('%1/%2/%3', sharedFolder, pCountProcessFiles, pCountFileName);

            permissionSet   =  new Set(Types::Class);
            permissionSet.add(new FileIOPermission(fileName, 'rw'));
            permissionSet.add(new FileIOPermission(newMoveFileDir, 'rw'));
            permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
            CodeAccessPermission::assertMultiple(permissionSet);

            if(System.IO.File::Exists(newMoveFileDir))
                System.IO.File::Delete(newMoveFileDir);

            System.IO.File::Move(filename, newMoveFileDir);

            CodeAccessPermission::revertAssert();
        }



Viewing all articles
Browse latest Browse all 175888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>