Visual C# | Files and folders exercise | Write a program to find the biggest file in a folder

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend one of more of the courses listed below!

Software ==> Visual C#  (79 exercises)
Version ==> Any version of C#
Topic ==> Files and folders  (3 exercises)
Level ==> Harder than average
Courses ==> Introduction to Visual C#  /  Fast track C#

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Create a new form containing a single button, and attach code to this to find the largest file in a given folder.

You can include the file path as a constant in your code.  To check the size of a file, use its Length property.

Here's the sort of thing you should see when you click on the button:

Results of search

Typical output from your program (although it certainly doesn't have to look like this).


Too easy?  Make the program recursive (so that it calls itself) to search through not just the folder given, but also all of its subfolders!

This page has 0 threads Add post