Игнорировать ошибки при удалении файла - C#
Формулировка задачи:
Если файла нету выводит ошибку, как можно игнорировать? чтобы он дальше шел и удалял
System.IO.File.Delete(@"C:\GamesMailRu\Warface\Game.log"); System.IO.File.Delete(@"C:\GamesMailRu\Warface\error.log"); System.IO.File.Delete(@"C:\GamesMailRu\Warface\server_profile.txt"); System.IO.File.Delete(@"D:\GamesMailRu\Warface\Game.log"); System.IO.File.Delete(@"D:\GamesMailRu\Warface\error.log"); System.IO.File.Delete(@"D:\GamesMailRu\Warface\server_profile.txt");
Решение задачи: «Игнорировать ошибки при удалении файла»
textual
Листинг программы
public static void DeleteIfExists(string path)
{
if(File.Exists(path))
{
File.Delete(path);
}
}