From ba8d8f0cd0a47065de9b8e5daa3019fed73b8c26 Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 10 Feb 2023 20:59:09 -0600 Subject: [PATCH] Delete functionality added --- Form1.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Form1.cs b/Form1.cs index 2cf638d..c697767 100644 --- a/Form1.cs +++ b/Form1.cs @@ -458,11 +458,19 @@ namespace photo_sorter { if (MessageBox.Show("Are you sure you want to delete this photo?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - MessageBox.Show("Poof! The photo would normally get deleted here if this function's code were completed, but alas, it is not, so this photo you have deemed to be subpar is still existing."); - } - else - { - MessageBox.Show("Forsooth! This photo is a keeper after all and would not have been deleted!"); + string src_fname = global.filenames[global.position]; + try + { + File.Delete(src_fname); + status_msg("Deleted file: " + src_fname, 2); + remove_index(global.position); + update_image(); + } + catch (IOException ex) + { + status_msg("Unable to delete " + src_fname + "!", 4); + MessageBox.Show(ex.ToString(), "Critical: IO Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } } public void prerender_init()