[Solved] CECS424 Assignment 4

30 $

SKU: [Solved] CECS424 Assignment 4 Category: Tag:

Lab Assignment 4

Overview

In this lab, you will use C# and LINQ to iterate files, to query, group and order data, and to create an XML document based on that data.

Implementation

You must follow these implementation guidelines:

  1. Create a C# console application.

This application has two command line arguments: A path to a folder and a name for a HTML report output file. The application collects all files with the same extension (converted to lower case) and determines for each extension, i.e. file type, the number of files and the total size of all files of this type.

  1. Implement a class with the following 4 static functions:

static IEnumerable<string> EnumerateFilesRecursively(string path)

Enumerate all files in a given folder recursively including the entire sub-folder hierarchy. You can use System.IO.Directory. Use the generator pattern (yield keyword) to implement the iterator.

static string FormatByteSize(long byteSize)

Format a byte size in human readable form. Use the following units: B, kB, MB, GB, TB, PB, EB, and ZB where 1kB = 1000B. The numerical value should be greater or equal to 1, less than 1000 and formatted with 2 fixed digits after the decimal point, e.g. 1.30kB.

static XDocument CreateReport(IEnumerable<string> files)

1 of 2

Create a HTML document containing a table with three columns: “Type”, “Count”, and “Size” for the file name extension (converted to lower case), the number of files with this type, and the total size of all files with this type, respectively.

You can use System.IO.FileInfo to get the size of a file with a given path.

Sort the table by the byte size value of the “Size” column in descending order.

Use your FormatByteSize function to format the value printed in the “Size” column.

Implement this function using LINQ queries making use of group by and orderby.
Use the System.Xml.Linq.XElement constructor to functionally construct the XML document.

public static void Main(string[] args)

Take two command line arguments. The first value is the path of the input folder and the second the path of the HTML report output file. Call the functions above to create the report

file.

  1. Do not use lists or arrays to store intermediate data. Instead you should use iterators to process the sequences of data element by element without storing it all.

Testing Your Code

Demonstrate that your console application works by creating a report file from some folder on your machine.

Deliverable: A private git repository named “CECS 424 Spring 2020 Assignment 4” with me [email protected] (and only for section 01 [email protected] as well) added as a reader, that contains all your C# source code as described above and an example HTML report file generated by your console application.

Due dates: Section 01: Monday 20 April 2020,

Section 03: Tuesday 21 April 2020,

Section 05: Friday 24 April 2020,

Section 07: Tuesday 21 April 2020, all at the beginning of lecture.

2 of 2

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CECS424 Assignment 4
30 $