-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
82 lines (59 loc) · 2.22 KB
/
Program.cs
File metadata and controls
82 lines (59 loc) · 2.22 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
73
74
75
76
77
78
79
80
81
82
using System;
using System.IO;
namespace DesktopBackupper {
internal class Program {
static void Main(string[] args) {
Console.WriteLine("Author: yuri, Github: https://github.com/dary1337");
Settings.setSettings();
Settings.setExcludes();
Console.WriteLine();
backup();
if (Directories.errors != 0) {
Console.WriteLine($"Backup complete, errors: {Directories.errors}");
return;
}
if (Settings.All[Settings.Keys.closeOnFinish] == "true") {
Environment.Exit(0);
return;
}
Console.WriteLine("No errors, u can close the program");
Console.ReadKey();
}
static void backup() {
Console.WriteLine($"Starting backup...");
string backupFrom = Settings.All[Settings.Keys.BackupFrom];
string backupTo = Settings.All[Settings.Keys.BackupTo];
if (backupTo == "") {
Settings.changeBackupTo();
backup();
return;
}
if (backupFrom == backupTo) {
Console.WriteLine("[backupFrom] and [backupTo] can't be the same!");
Settings.changeBackupTo();
backup();
return;
}
if (!Directory.Exists(backupFrom)) {
Console.WriteLine("[backupFrom] value contains not existed folder");
Settings.changeBackupTo();
backup();
return;
}
string dateName = DateTime.Now.ToString("dd_MM_yyyy-HH_mm_ss");
Directories.setTotal(backupFrom);
string folderName = new DirectoryInfo(backupFrom).Name;
string path = $"{(backupTo + "\\").Replace(@"\\", "\\")}{folderName}_{dateName}";
if (Settings.All[Settings.Keys.compressToArchive] == "true")
Directories.archive(backupFrom,
$"{path}.zip",
true);
else
Directories.copy(
backupFrom,
path,
true
);
}
}
}