WinForms – Loop through a form’s controls

Forms also have a collection of controls (Controls property) that you can loop through. This is useful for when you want to do something to multiple controls and don’t want to have to manually type out code to deal with individual controls. Here’s an example of looping through a form’s top-level controls: Note: In the … Read more

C# – Unit test doesn’t finish and stops all other tests from running

Problem You have a unit test that doesn’t finish, and it prevents other tests from running. There’s no indication that the test passed or failed. It just stops running. When you run all of the tests together, some tests might finish, but once this one bad test stops, it prevents other tests from running. This … Read more

C# – Find all empty folders

An empty folder: Has no files. Either has no folders, or has folders that are empty. In this article I’ll show code that finds empty folders based on this definition. Code that finds empty folders Given a root folder path, the following code recursively looks for empty folders and writes the empty folder path to … Read more