From 00a52543b8a082a3a48ab990b698b889d7c785fb Mon Sep 17 00:00:00 2001 From: Mira <56395159+TheXorog@users.noreply.github.com> Date: Sat, 17 Feb 2024 15:40:47 +0100 Subject: [PATCH] feat: Add Zip Tool --- CreateZipFolder/CreateZipFolder.csproj | 10 ++++++++++ CreateZipFolder/CreateZipFolder.sln | 25 +++++++++++++++++++++++++ CreateZipFolder/Program.cs | 24 ++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 CreateZipFolder/CreateZipFolder.csproj create mode 100644 CreateZipFolder/CreateZipFolder.sln create mode 100644 CreateZipFolder/Program.cs diff --git a/CreateZipFolder/CreateZipFolder.csproj b/CreateZipFolder/CreateZipFolder.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/CreateZipFolder/CreateZipFolder.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/CreateZipFolder/CreateZipFolder.sln b/CreateZipFolder/CreateZipFolder.sln new file mode 100644 index 0000000..9cc61ca --- /dev/null +++ b/CreateZipFolder/CreateZipFolder.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34511.84 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateZipFolder", "CreateZipFolder.csproj", "{FD8868F8-3953-4A89-918D-D8425F1AE760}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FD8868F8-3953-4A89-918D-D8425F1AE760}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD8868F8-3953-4A89-918D-D8425F1AE760}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD8868F8-3953-4A89-918D-D8425F1AE760}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD8868F8-3953-4A89-918D-D8425F1AE760}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5995513C-2C1E-4367-97C6-FC989288D411} + EndGlobalSection +EndGlobal diff --git a/CreateZipFolder/Program.cs b/CreateZipFolder/Program.cs new file mode 100644 index 0000000..ceca09f --- /dev/null +++ b/CreateZipFolder/Program.cs @@ -0,0 +1,24 @@ +using System.IO.Compression; + +var env = Environment.GetCommandLineArgs(); + +if (env.Length < 3) +{ + Console.WriteLine("Arguments required: [Directory] [OutputFile]"); + return 1; +} + +if (!new DirectoryInfo(env[1]).Exists) +{ + Console.WriteLine($"'{env[1]}' does not exist."); + return 1; +} + +if (new FileInfo(env[2]).Exists) +{ + Console.WriteLine($"'{env[2]}' already exists."); + return 1; +} + +ZipFile.CreateFromDirectory(env[1], env[2]); +return 0;