Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FileIOPermission : Unable to delete a file on server

533 views
Skip to first unread message

hs

unread,
Feb 4, 2010, 12:40:01 PM2/4/10
to
Hi I am getting the error (CLR oBject static method error) when i am
executing below code to send email from AX. PLeasse can you help ...

fileNameforEmail = winApi::getTempPath() + mail; // store attachment in a
temp location
info(fileNameforEmail);
info(p1.fileName());

if(fileNameforEmail)
{
handle=winapi::createFile(filenameforEmail);
perm = new FileIOPermission(fileNameforEmail,'w');
}
else
throw error("Temp Location unavailable");

winapi::copyFile(p1.fileName(),fileNameforEmail,true);

winapi::closeHandle(handle);

winapi::deleteFile(fileNameforEmail);//This lines give me error (CLR
oBject static method error) because temp file is locked ...not sure why? i
have tried to close the handle to the file but still not able to delete the
file. I have tried del command using msdos but get the error that file is
used by another process.

CodeAccessPermission::revertAssert();

Thanks in advance
--
hs

RB

unread,
Feb 4, 2010, 3:41:01 PM2/4/10
to
Another way to delete file:

System.IO.File::Delete(filename)

Axel Kühn

unread,
Feb 4, 2010, 3:48:02 PM2/4/10
to
Hi,

did you execute this code on server or on client?
If the code runs on server side, you have to use the Class WinApiServer
insted of WinApi.

For more dteails abut this helps check this article:
http://www.artofcreation.be/2009/04/08/winapi-rpc-1702-and-findfirstfilew/
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)

0 new messages