-
Notifications
You must be signed in to change notification settings - Fork 5
/
Program (5).cs
49 lines (46 loc) · 1.3 KB
/
Program (5).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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Task2
{
class Program
{
static void Main(string[] args)
{
try
{
string myDir = @"C:\Users\V\Desktop\SoftServe";
if (Directory.Exists(myDir))
{
string[] directories = Directory.GetDirectories(myDir);
Console.WriteLine("Directories:");
foreach (string dir in directories)
{
Console.WriteLine(dir);
}
directories = Directory.GetFiles(myDir);
Console.WriteLine("Files:");
foreach (string file in directories)
{
if (file.EndsWith(".txt"))
{
string rf = File.ReadAllText(file);
Console.WriteLine(rf);
}
}
}
}
catch (Exception)
{
Console.WriteLine("Error");
}
finally
{
Console.ReadKey();
}
}
}
}