Deleting text file using X++ code

Hi,

I am looking for deleting a txt file inside a folder using X++ code.

Any help!!

Regards

Nitish

WinApi::deleteFile(fileFullName);

thanks for your reply

But i am using a batch to perform this and WINAPI doesnt work in batch :(.

Any other solution.??

Use WinApiServer

Hi,

You can try the following code, it works in batch:

public server static boolean deleteFile(filename _filename)

{

FileIOPermission FileIOPerm;

;

FileIOPerm = new FileIOPermission(_filename,‘w’);

FileIOPerm.Demand();

System.IO.File::Delete(_Filename);

}

Hope it helps

regards,

Thomas

Thanks Thomas.

It worked.