WinapiServer::DeleteFile

hello!!

i have a problem to use a Winapi::DeleteFile in a Batch in Ax 2012.

This is my code:

FileIOPermission sourceFileWritePerm;

CodeAccessPermission::revertAssert();
sourceFileWritePerm = new FileIOPermission(filename, #io_write);
sourceFileWritePerm.assert();
WinAPIServer::deleteFile(filename);
CodeAccessPermission::revertAssert();

but the file is not deleted:(

Why??? i don’t understand!!!

Thanks for help me,

Antonio

Do you get any error? Does it work if you run it on server but not in batch?

In batch doesn’t run… i use “build complete CIL” before run, but…doesn’t delete file in a directory.

What “doesn’t run” means? It’s not a very detailed description of any problem. Do you get any error? (I already asked this one, didn’t I?)

Could you please use the debugger to analyze what’s going on in your code? We can’t do it for you.

I expressed myself badly…sorry!

It just does not delete the files, but does not return errors.

Are you saying that you’ve verified in the debugger that WinAPIServer::deleteFile(filename) gets called? It would be really strange if it did nothing without throwing any exception.

If you haven’t verified it, maybe the code runs differently than you think. I can’t comment the rest of code because you haven’t shown it.

I don’t understand why don’t delete file.

But i solve using a .net library (File.IO…).

Thank you so much for taking the time!!

Antonio

please let me know the solution I to face same kind of issue