-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
62 lines (56 loc) · 1.58 KB
/
Program.cs
File metadata and controls
62 lines (56 loc) · 1.58 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
using System;
class Program
{
const string PathDest = $@"C:\Users\T-Gamer\Documents\Backups\";
static void Main(string[] args)
{
try
{
string[] PathsSrc = new string[4]
{
"acd","schedule","bal21","tss"
};
int cont = 0;
while (cont <= PathsSrc.Length)
{
foreach (string str in PathsSrc)
{
string Src = $@"C:\{str}\appserver.txt";
string Dest = $@"{PathDest}\{str}";
if (ValidPath(str) == false)
{
Directory.CreateDirectory(Dest);
}
if (ValidFile(NameFile(Dest)) == false)
{
File.Copy(sourceFileName: Src,
destFileName: NameFile(Dest),
overwrite: true);
}
}
cont++;
}
}catch (Exception)
{
Console.WriteLine("Erro");
throw;
}
}
static string NameFile(string a)
{
DateTime dt = DateTime.Now;
string DateFormat = dt.ToString("yyyyMMdd");
string cNameFile = $"{a}/appserver_backup_{DateFormat}.ini";
return cNameFile;
}
static bool ValidFile(string a)
{
Boolean file = File.Exists(a);
return file;
}
static bool ValidPath(string a)
{
Boolean path = Directory.Exists($@"{PathDest}\{a}");
return path;
}
}