563 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
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 above folder has 4 files in:
The four files in the above folder. Your task is to add the file sizes together, and report back!
If you right-click on the files to show their properties, you should see this:
The total size for all of the files is 210,304 bytes - something we intend to prove with an SSIS package!
To start, create a new package called File Sizes, and add the following variables to it:
We'll use the first variable to accumulate the total file size (set it to 0) and the second one to hold the file name/path for each file in turn.
Create a Foreach Loop container to loop over the files in the above folder, calling a script task for each:
Remember to assign your FilePath variable to the Foreach Loop container, to tell SSIS where each file name/path will be stored.
Assign your variables to the script task:
The script will need to read each variable's file path (so this is read-only), but will need to add to the cumulative size (so this is read-write).
In the script for the script task, remember to reference the files and folders namespace:
// reference namespace
Now write the script to get a pointer to the file whose name and path are stored in the FilePath variable, get the size of this file (using its Length property) and add this to the CumulativeSize read/write variable. Here are a couple of lines your code could include:
// get a reference to this file
var thisFile = new FileInfo(thisFilePath);
// get the size of this file
long fileSize = thisFile.Length;
When you've finished, add another script task to report what you've found:
The final script task should display the total file size accumulated in the variable.
Here's what your package should show when you run it:
Yeah - the correct result!
Close your package down, reflecting on how you might use this in "real" life.
25 Aytoun Street