From ebf5b9e30457c2d5d535da7630f6447c98d53cb9 Mon Sep 17 00:00:00 2001 From: FUH22860 Date: Tue, 6 Dec 2022 13:23:56 +0100 Subject: [PATCH] Copy files to backup folder in home --- Update.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Update.cs b/Update.cs index 53e089f..1ad1963 100644 --- a/Update.cs +++ b/Update.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.IO; public class Update { public static string getHomePath() { string homePath = string.Empty; @@ -41,13 +42,15 @@ public class Update { string sourcePath = @"/etc/"; string targetPath = getHomePath(); - string sourceFile = System.IO.Path.Combine(sourcePath, fileName); - string destFile = System.IO.Path.Combine(targetPath, fileName); + string backupPath = targetPath + "/backup/"; - System.IO.Directory.CreateDirectory(targetPath); + string sourceFile = Path.Combine(sourcePath, fileName); + string destFile = Path.Combine(backupPath, fileName); - System.IO.File.Copy(sourceFile, destFile, true); + Directory.CreateDirectory(backupPath); - return $"Copied {fileName} to {targetPath}"; + File.Copy(sourceFile, destFile, true); + + return $"Copied {fileName} to {backupPath}"; } } \ No newline at end of file