Thursday, January 7, 2010

How to Assert multiple file IO permission

server static void CAP_copyFile(FilenameOpen _attachmentFilename, str _attachmentsFolder)
{
Set permissionSet; ; // Revert permissions
CodeAccessPermission::revertAssert();
permissionSet = new Set(Types::Class);
permissionSet.add(new FileIoPermission(_attachmentFilename,'r'));
permissionSet.add(new FileIoPermission(_attachmentsFolder,'w'));
CodeAccessPermission::assertMultiple(permissionSet);
// Move to processed folder
// BP Deviation Documented

winAPI::copyFile(_attachmentFilename,_attachmentsFolder,true);
CodeAccessPermission::revertAssert();
}