When we deleting file by using WinAPIServer class we get following issue ClrObject static method invocation error.
Solution:
Deleting file does not exist in the particular location. So the error occured..
i) We need to check file exist or not by using System.IO.File::Exists("FileName") method
Sample Code:
static void Delfile(Args _args)
{
FilePath filePath;
FileIOPermission fileIOPermission;
;
filePath = @'C:\customer.xml';
fileIOPermission = new FileIOPermission(filePath, 'w');
CodeAccessPermission::revertAssert();
//Here we adding File Exists method
if(System.IO.File::Exists(filePath))
{
WinAPIServer::deleteFile(filePath);
}
}
Solution:
Deleting file does not exist in the particular location. So the error occured..
i) We need to check file exist or not by using System.IO.File::Exists("FileName") method
Sample Code:
static void Delfile(Args _args)
{
FilePath filePath;
FileIOPermission fileIOPermission;
;
filePath = @'C:\customer.xml';
fileIOPermission = new FileIOPermission(filePath, 'w');
CodeAccessPermission::revertAssert();
//Here we adding File Exists method
if(System.IO.File::Exists(filePath))
{
WinAPIServer::deleteFile(filePath);
}
}
No comments:
Post a Comment