public static bool DeleteFile(FileInfo file)
{
try
{
file.Delete();
}
catch (IOException ioe)
{
LogError(ioe.Message + "\n" + ioe.StackTrace);
}
catch (System.Security.SecurityException soe)
{
LogError(soe.Message + "\n" + soe.StackTrace);
}
catch (UnauthorizedAccessException ue)
{
LogError(ue.Message + "\n" + ue.StackTrace);
}
if (file.Exists)
return false; //Didn't delete successfully
else
return true; //Deleted
}