From 7f866d3f98a5167ebcb834ebea5c3ed93126d52c Mon Sep 17 00:00:00 2001 From: Josh Creek Date: Sun, 29 Aug 2021 15:49:26 +0100 Subject: [PATCH] feat(*): Add DeleteLocalFile --- YouTubeChannelDownloader/Program.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/YouTubeChannelDownloader/Program.cs b/YouTubeChannelDownloader/Program.cs index c1368f6..55c6496 100644 --- a/YouTubeChannelDownloader/Program.cs +++ b/YouTubeChannelDownloader/Program.cs @@ -145,5 +145,24 @@ namespace YouTubeChannelDownloader Console.WriteLine("SFTP done"); } + + private static void DeleteLocalFile(string pathString) + { + try + { + // Check if file exists with its full path + if (File.Exists(pathString)) + { + // If file found, delete it + File.Delete(pathString); + Console.WriteLine("Local file deleted."); + } + else Console.WriteLine("Local file not found"); + } + catch (IOException ioExp) + { + Console.WriteLine(ioExp.Message); + } + } } }