Search files in C# recursively

I found this piece of code to search a for a file that containing a pattern (extension, part of the name)  void DirSearch(string dir, string pattern) {     try     {         foreach (string d in Directory.GetDirectories(dir))         {             foreach (string f in Directory.GetFiles(d, pattern))             {                 Console.WriteLine(“File found: {0}”, f);             }             DirSearch(d);…

4

Get Print Jobs using WMI and ManagmentObjects

I found a way to get the print jobs from the spoiler using Management objects and WMI public static void GetPrintJobs() {     string searchQuery = “SELECT * FROM Win32_PrintJob”;     ManagementObjectSearcher searchPrintJobs = new ManagementObjectSearcher(searchQuery);     ManagementObjectCollection prntJobCollection = searchPrintJobs.Get();     foreach (ManagementObject prntJob in prntJobCollection)     {         try         {             string…

1