|
1 | | -using System.Collections; |
2 | | -using Disc_Viewer.src.scripts; |
| 1 | +using Disc_Viewer.src.scripts; |
3 | 2 |
|
4 | 3 | public class Program |
5 | 4 | { |
6 | 5 | public static async Task Main() |
7 | 6 | { |
8 | | - Console.WriteLine("Welcome to Disc Viewer!\nPlease enter folder directory"); |
| 7 | + Console.WriteLine("Welcome to Disc Viewer!"); |
9 | 8 |
|
10 | | - string? directory = Console.ReadLine(); |
11 | | - |
12 | | - if (string.IsNullOrWhiteSpace(directory)) |
| 9 | + while (true) |
13 | 10 | { |
14 | | - Console.WriteLine("No directory entered!"); |
15 | | - return; |
16 | | - } |
| 11 | + Console.WriteLine("Please enter folder directory"); |
17 | 12 |
|
18 | | - if (!Directory.Exists(directory)) |
19 | | - { |
20 | | - Console.WriteLine(directory + " does not exists"); |
21 | | - return; |
22 | | - } |
| 13 | + string? directory = Console.ReadLine(); |
| 14 | + |
| 15 | + if (string.IsNullOrWhiteSpace(directory)) |
| 16 | + { |
| 17 | + Console.WriteLine("No directory entered!"); |
| 18 | + continue; |
| 19 | + } |
23 | 20 |
|
24 | | - DirectoryInfo directoryInfo = new(directory); |
25 | | - long directorySize = await GetDirectorySizeAsync(directoryInfo); |
26 | | - Console.WriteLine($"Size of {directory} is {Utils.GetSizeText(directorySize)}"); |
| 21 | + if (!Directory.Exists(directory)) |
| 22 | + { |
| 23 | + Console.WriteLine(directory + " does not exists"); |
| 24 | + continue; |
| 25 | + } |
27 | 26 |
|
28 | | - List<FileObject> fileObjects = await GetFileObjectsAsync(directory); |
29 | | - DisplayFileObjects(fileObjects); |
| 27 | + DirectoryInfo directoryInfo = new(directory); |
| 28 | + long directorySize = await GetDirectorySizeAsync(directoryInfo); |
| 29 | + Console.WriteLine($"Size of {directory} is {Utils.GetSizeText(directorySize)}"); |
| 30 | + |
| 31 | + List<FileObject> fileObjects = await GetFileObjectsAsync(directory); |
| 32 | + DisplayFileObjects(fileObjects); |
| 33 | + } |
30 | 34 | } |
31 | 35 |
|
32 | 36 | private static async Task<long> GetDirectorySizeAsync(DirectoryInfo directoryInfo) |
|
0 commit comments