Advertisement
Guest User

recursion c#

a guest
Mar 15th, 2013
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using System.IO;
  16.  
  17. namespace WpfApplication2
  18. {
  19.     /// <summary>
  20.     /// Interaction logic for MainWindow.xaml
  21.     /// </summary>
  22.     public partial class MainWindow : Window
  23.     {
  24.         public MainWindow()
  25.         {
  26.             InitializeComponent();
  27.         }
  28.  
  29.         private void Button_Click_1(object sender, RoutedEventArgs e)
  30.         {
  31.             string sourcePath = @"C:\temp\";            
  32.  
  33.             static void DirSearch(string sourcePath)
  34.             {
  35.                 try
  36.                 {
  37.                     foreach (string d in Directory.GetDirectories(sourcePath))
  38.                     {
  39.                         foreach (string f in Directory.GetFiles(d))
  40.                         {
  41.                             listBox1.Items.Add(f);
  42.                         }
  43.                         DirSearch(d);
  44.                     }
  45.                 }                      
  46.                 catch (Exception ex)
  47.                 {
  48.                     listBox1.Items.Add(ex.Message);
  49.                 }                
  50.             }
  51.         }
  52.  
  53.  
  54.  
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement