-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
61 lines (59 loc) · 2.12 KB
/
Program.cs
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
using System;
using System.IO;
namespace DisciplesMerger
{
partial class Program
{
static void Main(string[] args)
{
var files = GetFiles();
if (files.Length == 0)
{
Console.WriteLine("No files found. Program will exit.");
Console.ReadKey();
return;
}
switch (GetUserConsent())
{
case true:
string[] filenames = new string[files.Length];
for (int i = 0; i < files.Length; i++)
{
filenames[i] = files[i].FullName;
}
var disciplesMerger = new DisciplesMerger(filenames);
disciplesMerger.Merge();
Console.WriteLine("Done");
break;
case false:
break;
}
Console.ReadKey();
}
private static FileInfo[] GetFiles()
{
var launchPath = Environment.CurrentDirectory;
var databasesPath = Path.Combine(launchPath, "Databases");
var databaseFolder = Directory.CreateDirectory(databasesPath);
var files = databaseFolder.GetFiles();
Console.WriteLine("Enumerating files in " + databasesPath);
Console.WriteLine("Found {0} files as listed below:", files.Length);
for (int i = 0; i < files.Length; i++)
{
Console.WriteLine("{0}. " + files[i], i + 1);
}
return files;
}
private static bool GetUserConsent()
{
string response;
do
{
Console.WriteLine("Are they all databases? Yes(y) to proceed, No (n) to cancel or exit.");
var input = Console.ReadLine();
response = input.ToLower().Contains("y") ? "yes" : input.ToLower().Contains("n") ? "exit" : "invalid";
} while (!response.Equals("yes") && !response.Equals("exit"));
return response.Equals("yes") ? true : false;
}
}
}