fork(1) download
  1. public partial class Form1 : Form
  2. {
  3. string dirblank = "";
  4. string fileblank = " ";
  5. string[] sub;
  6. int s = 0;
  7.  
  8. FolderBrowserDialog fbd = new FolderBrowserDialog();
  9.  
  10. public Form1()
  11. {
  12. InitializeComponent();
  13. }
  14.  
  15. private void button1_Click(object sender, EventArgs e)
  16. {
  17. dirblank = "";
  18. fileblank = " ";
  19.  
  20. listBox1.Items.Clear();
  21. fbd.Description = "フォルダ指定";
  22. fbd.RootFolder = Environment.SpecialFolder.Desktop;
  23. fbd.SelectedPath = @"C:\Windows";
  24. fbd.ShowNewFolderButton = true;
  25.  
  26. if (fbd.ShowDialog(this) == DialogResult.OK)
  27. {
  28. textBox1.Text = fbd.SelectedPath;
  29. }
  30.  
  31. //指定ディレクトリの中のサブディレクトリを格納
  32. string[] folder = System.IO.Directory.GetDirectories(fbd.SelectedPath, "*", System.IO.SearchOption.AllDirectories);
  33.  
  34. //指定ディレクトリの中のファイルを格納
  35. string[] file1 = System.IO.Directory.GetFiles(fbd.SelectedPath, "*", System.IO.SearchOption.TopDirectoryOnly);
  36.  
  37. //指定ディレクトリ名を表示
  38. string f = System.IO.Path.GetFileName(fbd.SelectedPath);
  39.  
  40. listBox1.Items.Add(f + "[フォルダ]");
  41.  
  42. //指定ディレクトリの中のファイルを表示させる
  43. FileName(file1,folder);
  44. }
  45.  
  46. //指定ディレクトリ、サブディレクトリの中のファイル名を表示させる処理
  47. int x = 0;
  48. private void FileName(string[] file, string[] folder)
  49. {
  50. //各ディレクトリにあるファイルの数だけ処理。
  51. for (int i = 0; i < file.Length; i++)
  52. {
  53. //ファイル名を表示
  54. file[i] = System.IO.Path.GetFileName(file[i]);
  55. listBox1.Items.Add(fileblank + file[i] + "[ファイル]");
  56. }
  57. listBox1.Items.Add("");
  58.  
  59. for (int i = x; x < folder.Length; x++)
  60. {
  61. file = System.IO.Directory.GetFiles(folder[x], "*", System.IO.SearchOption.TopDirectoryOnly);
  62. sub = Directory.GetDirectories(folder[x]);
  63. folder[x] = System.IO.Path.GetFileName(folder[x]);
  64. dirblank += " ";
  65. fileblank = dirblank;
  66. fileblank += " ";
  67. listBox1.Items.Add(dirblank + folder[x] + "[フォルダ]");
  68. x++;
  69. FileName(file, folder);
  70. }
  71. }
  72. }
  73. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(73,4): error CS1525: Unexpected symbol `}'
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty