From 9a1bb6bffd55db6f8a1197a545cb6b0a5765ef93 Mon Sep 17 00:00:00 2001 From: Florian Dubois Date: Fri, 25 Jun 2021 18:57:22 +0200 Subject: [PATCH] Fix an exception when deleting the application's data --- Form1.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Form1.cs b/Form1.cs index d286442..02892eb 100644 --- a/Form1.cs +++ b/Form1.cs @@ -159,12 +159,15 @@ private void Form1_Close(object sender, FormClosingEventArgs e) if (cleanupOnShutDown) ToastNotificationManagerCompat.Uninstall(); - // Then, all saved avatars. - var files = Directory.GetFiles("images"); - - foreach (var file in files) + // Then, all saved avatars (if the save folder exists). + if (Directory.Exists("images")) { - File.Delete(file); + var files = Directory.GetFiles("images"); + + foreach (var file in files) + { + File.Delete(file); + } } }