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.

Software ==> Visual C#  (79 exercises)
Version ==> Any version of C#
Topic ==> Files and folders  (3 exercises)
Level ==> Harder than average
Subject ==> C# training

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!

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post