-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
65 lines (54 loc) · 1.84 KB
/
Program.cs
File metadata and controls
65 lines (54 loc) · 1.84 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
using System;
using GZipTest.Model;
namespace GZipTest
{
internal class Program
{
private static void Main(string[] args)
{
try
{
bool isCompress = true;
if (args.Length < 3)
{
throw new Exception("Вы не ввели команду программы,имя исходного и результирующего файла");
}
if (args[0] != "compress")
{
isCompress = false;
if (args[0] != "decompress")
{
throw new Exception($"Команда \"{args[0]}\" не существует");
}
}
if (args.Length < 2)
{
throw new Exception("Вы не ввели имя исходного и результирующего файла");
}
if (args.Length < 3)
{
throw new Exception("Вы не ввели имя результирующего файла");
}
var readingFile = args[1];
var writingFile = args[2];
var gzip = new Gzip();
if (isCompress)
{
gzip.Compress(readingFile, writingFile);
}
else
{
gzip.Decompress(readingFile, writingFile);
}
Console.WriteLine("0");
Console.ReadKey();
}
catch (Exception e)
{
Console.WriteLine($"Error message: {e.Message}");
Console.WriteLine("1");
Console.ReadKey();
}
}
}
}