01.
using
System;
02.
using
System.IO;
03.
using
System.Windows.Forms;
04.
05.
namespace
Folder
06.
{
07.
public
partial
class
Form1 : Form
08.
{
09.
public
Form1()
10.
{
11.
InitializeComponent();
12.
}
13.
14.
private
void
button1_Click(
object
sender, EventArgs e)
15.
{
16.
folderBrowserDialog1.Description =
"フォルダを選択"
;
17.
folderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer;
18.
19.
20.
folderBrowserDialog1.SelectedPath = @
"C:\Program Files\Microsoft Office"
;
21.
22.
folderBrowserDialog1.ShowNewFolderButton =
false
;
23.
24.
25.
if
(folderBrowserDialog1.ShowDialog(
this
) == DialogResult.OK)
26.
{
27.
Console.WriteLine(folderBrowserDialog1.SelectedPath);
28.
29.
string
path = folderBrowserDialog1.SelectedPath;
30.
31.
string
[] files = Directory.GetFiles(path,
"*.*"
, SearchOption.AllDirectories);
32.
this
.listBox1.Items.AddRange(files);
33.
34.
}
35.
}
36.
}
37.
}