-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
72 lines (67 loc) · 2.2 KB
/
Program.cs
File metadata and controls
72 lines (67 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.IO;
using System.IO.Compression;
namespace core_zip
{
class Program
{
static void Zipper(string folder, string file)
{
ZipFile.CreateFromDirectory(folder, file);
}
static void Main(string[] args)
{
string inFolder2zip = "";
string inZipFilename = "";
string inOverwrite = "";
if (args.Length == 0)
{
Console.WriteLine("What folder would you like to zip? ");
inFolder2zip = Console.ReadLine();
Console.WriteLine("What would you like to Call the zip?");
inZipFilename = Console.ReadLine();
if (File.Exists(inZipFilename))
{
Console.WriteLine("Would you like to overwrite the existing file? [y/N]");
inOverwrite = Console.ReadLine();
if (inOverwrite == "y" || inOverwrite == "Y")
{
File.Delete(inZipFilename);
Zipper(inFolder2zip, inZipFilename);
}
else
{
Console.WriteLine("Aborting...");
}
}
else
{
Zipper(inFolder2zip, inZipFilename);
}
}
else
{
if (args.Length == 2)
{
if (!(File.Exists(args[1])))
{
Zipper(args[0], args[1]);
}
}
else if (args.Length == 3 && args[0] == "-f")
{
if(File.Exists(args[2]))
{
File.Delete(args[2]);
}
Zipper(args[1], args[2]);
}
else
{
Console.WriteLine("Improper usage");
Console.WriteLine("Proper usage: core-zip [-f] foldername zipfilename");
}
}
}
}
}