-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
56 lines (48 loc) · 1.92 KB
/
Copy pathProgram.cs
File metadata and controls
56 lines (48 loc) · 1.92 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
using System;
using System.IO;
namespace GarbageCleaner
{
class Program
{
static void Main()
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("Coded by Evilprince2009");
while (true)
{
DirectoryInput:
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine("Put a directory or folder path.");
string path = Console.ReadLine() + @"\";
if (!Directory.Exists(path))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("That's not a valid Directory !");
goto DirectoryInput;
}
ExtensionInput:
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine("Enter extension.");
string extension = "*." + Console.ReadLine();
if (extension.Length < 3)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Enter a valid extension !");
goto ExtensionInput;
}
string[] fileBuffer = Directory.GetFiles(path, extension, SearchOption.TopDirectoryOnly);
int counter = fileBuffer.Length;
Console.WriteLine("File(s) found with the extension " + extension.Trim('*') + " in directory:-" + counter);
foreach (var buffer in fileBuffer)
{
FileInfo file = new (buffer);
file.Delete();
Console.WriteLine("File(s) left - " + --counter);
}
Console.WriteLine("Start over? Type yes or no.");
string response = Console.ReadLine().ToLower();
if (response == "no") break;
}
}
}
}