In this video, I’ll answer the question “How do I copy all files in directories and subdirectories using C#?”.

Using WPF and C#, we will make use of the Directory, DirectoryInfo, File, and FileInfo classes provided by .NET Core to create a method that recursively loops and copies all files in directories, including all files in subdirectories, into another location on disk.

Once we have written our logic to copy all files in directories and subdirectories, we will then move that work onto a worker thread using Tasks and async await.

This will keep our UI responsive while the long running task of copying a large number of files executes on another thread. This question comes from a comment in one of my previous videos “How to Report Progress with Async/Await in .NET Core 3”.

You can watch that video here: https://youtu.be/zQMNFEz5IVU

Brian Lagunas

View all posts

Follow Me

Follow me on Twitter, subscribe to my YouTube channel, and watch me stream live on Twitch.