01.
using
System;
02.
using
System.IO;
03.
04.
namespace
Basic
05.
{
06.
class
Program
07.
{
08.
static
void
Main(
string
[] args)
09.
{
10.
string
path = Directory.GetCurrentDirectory();
11.
Console.WriteLine($
"カレントディレクトリは {path} です"
);
12.
13.
Console.WriteLine(
"------------------------------"
);
14.
15.
string
[] files = Directory.GetFiles(path);
16.
foreach
(
string
file
in
files)
17.
{
18.
Console.WriteLine(file);
19.
}
20.
21.
Console.WriteLine(
"------------------------------"
);
22.
23.
24.
path = @
"C:\Program Files\Microsoft Office"
;
25.
files = Directory.GetFiles(path);
26.
foreach
(
string
file
in
files)
27.
{
28.
Console.WriteLine(file);
29.
}
30.
31.
Console.WriteLine(
"------------------------------"
);
32.
33.
34.
files = Directory.GetFiles(path,
"*.*"
, SearchOption.AllDirectories);
35.
foreach
(
string
file
in
files)
36.
{
37.
Console.WriteLine(file);
38.
}
39.
40.
Console.WriteLine(
"------------------------------"
);
41.
42.
43.
files = Directory.GetFiles(path,
"*.dll"
, SearchOption.AllDirectories);
44.
foreach
(
string
file
in
files)
45.
{
46.
Console.WriteLine(file);
47.
}
48.
49.
Console.ReadLine();
50.
}
51.
}
52.
}