From the course: C# and .NET Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Solution: Files and directories

Solution: Files and directories - C# Tutorial

From the course: C# and .NET Essential Training

Solution: Files and directories

(upbeat music) - [Instructor] Okay, let's review my solution to this challenge and you can compare it to yours along the way. So in my code, I start with a couple of string contents that contain the name of the folder that's going to be scanned along with name of the results file that's going to be created. These are followed by the variables I'm going to use to build the information that we need to summarize things like the number of each file type, the total file count, total number of bytes, and so on. This function is office file, determines if a given name is an office file. Now it's a very simplistic test that just looks at the suffix of the file name to see if it ends in a known file extension for office files. Next, we get into the main algorithm for the program. So I create a DirectoryInfo object for the folder that we're going to scan. Then, the code uses the enumerate files function to iterate over…

Contents