C#判断文件是否存在然后执行删除
public void DeleteOldWords(string[] filesToDelete)
{
_logger.LogInformation("delete old word documents");
foreach (string file in filesToDelete)
{
if (System.IO.File.Exists(Path.GetFullPath(file)))
{
File.Delete(Path.GetFullPath(file));
}
else
{
_logger.LogInformation(Path.GetFullPath(file) + " not exist..");
}
}
}