You need to do two things:
First -
deallocate the file from the memory (since you are adding it as an attachment). From MSDN, I see that it has the following syntax:
//start your process
handle = WinApiServer::createFile(fileName);
//end the process
//close the handle.
WinApiServer::closeHandle(handle);
And also, I bet you forgot to
assert the fileIOPermission on the file before invoking the deleteFile method.
It should be done like this:
FileIOPermission = new FileIOPermission(fileName, 'abracadabra');
fileIOPermission.assert();
WinApiServer::deleteFile(fileName);
Hope that helps.