-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
79 lines (68 loc) · 3.24 KB
/
Program.cs
File metadata and controls
79 lines (68 loc) · 3.24 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
// <copyright file="Program.cs" company="Tortillas-Inc">
// Copy me, no rights reserved.
// </copyright>
namespace SearchInWordFiles
{
using System;
using System.Collections.Generic;
using System.IO;
/// <summary>
/// Class containing the main methods used to search among word files.
/// </summary>
internal class Program
{
/// <summary>
/// Method that allows to choose what type of research is being used.
/// </summary>
public static void SelectFonction()
{
// Location of the .exe file.
string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
// Folder of the .exe file.
string directory = System.IO.Path.GetDirectoryName(path);
DirectoryInfo directoryInfo = new DirectoryInfo(directory);
Console.WriteLine("Types de recherche :");
Console.WriteLine("1 : Rechercher une région par correspondance exacte.");
Console.WriteLine("2 : Rechercher une région par correspondance incomplète.");
Console.WriteLine("3 : Rechercher partout un mot / une phrase.");
string selectedFunction = ReadWriteConsoleManagement.GetSaisieUtilisateur(
startMessage: "Choisissez le type de recherche :",
errorMessage: "Cette recherche n'existe pas.",
acceptedValues: new List<string>() { "1", "2", "3" });
Console.Clear();
switch (selectedFunction)
{
case "1":
string regionComplete = ReadWriteConsoleManagement.GetSaisieUtilisateur("Rentrez la région complète (en respectant la case) à chercher parmi les documents word du dossier :", "Veuillez rentrer la région (en respectant la case).");
WordSearch.RecursiveSearchRegionInWordFiles(directoryInfo, regionComplete);
break;
case "2":
string regionPartielle = ReadWriteConsoleManagement.GetSaisieUtilisateur("Rentrez un mot appartenant à la région à chercher parmi les documents word du dossier :", "Veuillez rentrer un mot appartenant à la région.");
WordSearch.RecursiveSearchRegionInWordFilesWithPartialWord(directoryInfo, regionPartielle);
break;
case "3":
string motPhrase = ReadWriteConsoleManagement.GetSaisieUtilisateur("Rentrez un mot / une phrase à chercher parmi les documents word du dossier :", "Veuillez rentrer un mot / une phrase.");
WordSearch.RecursiveSearchWordInFiles(directoryInfo, motPhrase);
break;
}
}
/// <summary>
/// Main method, launched first.
/// </summary>
/// <param name="args">Arguments of the program (not used. Yet ?).</param>
private static void Main(string[] args)
{
try
{
Program.SelectFonction();
Console.WriteLine("Recherche terminée.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ExceptionsHandler.ConcatException(ex));
Console.ReadLine();
}
}
}
}