using System;
using System.Collections .Generic ;
using System.ComponentModel ;
using System.Data ;
using System.Drawing ;
using System.IO ;
using System.Linq ;
using System.Text ;
using System.Threading .Tasks ;
using System.Windows .Forms ;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1( )
{
InitializeComponent( ) ;
}
private void button1_Click( object sender, EventArgs e)
{
FolderBrowserDialog dlg = new FolderBrowserDialog( ) ;
if ( dlg.ShowDialog ( ) != DialogResult.OK )
{
return ;
}
textBox1.Text = dlg.SelectedPath ;
listBox1.Items .Clear ( ) ;
Stack< Tuple< string, int>> stack = new Stack< Tuple< string, int>> ( ) ;
stack.Push ( new Tuple< string, int> ( dlg.SelectedPath , 0 ) ) ;
while ( stack.Count > 0 )
{
var temp = stack.Pop ( ) ;
var dir = temp.Item1 ;
var rank = temp.Item2 ;
listBox1.Items .Add (
new String( ' ' , rank * 2 ) +
Path.GetFileName ( dir) + "[フォルダ]" ) ;
var subfs = Directory.GetFiles ( dir, "*" ) ;
foreach ( var f in subfs)
{
listBox1.Items .Add (
new String( ' ' , ( rank + 1 ) * 2 ) +
Path.GetFileName ( f) + "[ファイル]" ) ;
}
if ( subfs.Length > 0 )
{
listBox1.Items .Add ( "" ) ;
}
var subds = Directory.GetDirectories ( dir, "*" ) ;
foreach ( var d in subds)
{
stack.Push ( new Tuple< string, int> ( d, rank + 1 ) ) ;
}
}
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkNvbXBvbmVudE1vZGVsOwp1c2luZyBTeXN0ZW0uRGF0YTsKdXNpbmcgU3lzdGVtLkRyYXdpbmc7CnVzaW5nIFN5c3RlbS5JTzsKdXNpbmcgU3lzdGVtLkxpbnE7CnVzaW5nIFN5c3RlbS5UZXh0Owp1c2luZyBTeXN0ZW0uVGhyZWFkaW5nLlRhc2tzOwp1c2luZyBTeXN0ZW0uV2luZG93cy5Gb3JtczsKCm5hbWVzcGFjZSBXaW5kb3dzRm9ybXNBcHBsaWNhdGlvbjEKewogICAgcHVibGljIHBhcnRpYWwgY2xhc3MgRm9ybTEgOiBGb3JtCiAgICB7CiAgICAgICAgcHVibGljIEZvcm0xKCkKICAgICAgICB7CiAgICAgICAgICAgIEluaXRpYWxpemVDb21wb25lbnQoKTsKICAgICAgICB9CgogICAgICAgIHByaXZhdGUgdm9pZCBidXR0b24xX0NsaWNrKG9iamVjdCBzZW5kZXIsIEV2ZW50QXJncyBlKQogICAgICAgIHsKICAgICAgICAgICAgRm9sZGVyQnJvd3NlckRpYWxvZyBkbGcgPSBuZXcgRm9sZGVyQnJvd3NlckRpYWxvZygpOwogICAgICAgICAgICBpZiAoZGxnLlNob3dEaWFsb2coKSAhPSBEaWFsb2dSZXN1bHQuT0spCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICAKICAgICAgICAgICAgdGV4dEJveDEuVGV4dCA9IGRsZy5TZWxlY3RlZFBhdGg7CiAgICAgICAgICAgIGxpc3RCb3gxLkl0ZW1zLkNsZWFyKCk7CiAgICAgICAgICAgIFN0YWNrPFR1cGxlPHN0cmluZywgaW50Pj4gc3RhY2sgPSBuZXcgU3RhY2s8VHVwbGU8c3RyaW5nLCBpbnQ+PigpOwogICAgICAgICAgICBzdGFjay5QdXNoKG5ldyBUdXBsZTxzdHJpbmcsIGludD4oZGxnLlNlbGVjdGVkUGF0aCwgMCkpOwoKICAgICAgICAgICAgd2hpbGUgKHN0YWNrLkNvdW50ID4gMCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgdmFyIHRlbXAgPSBzdGFjay5Qb3AoKTsKICAgICAgICAgICAgICAgIHZhciBkaXIgPSB0ZW1wLkl0ZW0xOwogICAgICAgICAgICAgICAgdmFyIHJhbmsgPSB0ZW1wLkl0ZW0yOwoKICAgICAgICAgICAgICAgIGxpc3RCb3gxLkl0ZW1zLkFkZCgKICAgICAgICAgICAgICAgICAgICBuZXcgU3RyaW5nKCcgJywgcmFuayAqIDIpICsKICAgICAgICAgICAgICAgICAgICBQYXRoLkdldEZpbGVOYW1lKGRpcikgKyAiW+ODleOCqeODq+ODgF0iKTsKCiAgICAgICAgICAgICAgICB2YXIgc3ViZnMgPSBEaXJlY3RvcnkuR2V0RmlsZXMoZGlyLCAiKiIpOwogICAgICAgICAgICAgICAgZm9yZWFjaCAodmFyIGYgaW4gc3ViZnMpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgbGlzdEJveDEuSXRlbXMuQWRkKAogICAgICAgICAgICAgICAgICAgICAgICBuZXcgU3RyaW5nKCcgJywgKHJhbmsgKyAxKSAqIDIpICsKICAgICAgICAgICAgICAgICAgICAgICAgUGF0aC5HZXRGaWxlTmFtZShmKSArICJb44OV44Kh44Kk44OrXSIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN1YmZzLkxlbmd0aCA+IDApCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgbGlzdEJveDEuSXRlbXMuQWRkKCIiKTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICB2YXIgc3ViZHMgPSBEaXJlY3RvcnkuR2V0RGlyZWN0b3JpZXMoZGlyLCAiKiIpOwogICAgICAgICAgICAgICAgZm9yZWFjaCAodmFyIGQgaW4gc3ViZHMpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgc3RhY2suUHVzaChuZXcgVHVwbGU8c3RyaW5nLCBpbnQ+KGQsIHJhbmsgKyAxKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0K
compilation info
prog.cs(4,14): error CS0234: The type or namespace name `Data' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(9,24): error CS0234: The type or namespace name `Tasks' does not exist in the namespace `System.Threading'. Are you missing an assembly reference?
prog.cs(10,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
Compilation failed: 3 error(s), 0 warnings
stdout