Write the program FileComparison that compares two files. Two files have been provided for you, Quote.txt and Quote.docx, both containing movie quotes and are located in the /root/sandbox/ directory Note: you will not be able to see the Quote.docx file. Next write the file comparison application that displays the sizes of the two files as well as the ratio of their sizes to each other. To discover a file’s size, you can create a System.IO.FileInfo object using statements such as the following, where FILE_NAME is a string that contains the name of the file, and size has been declared as an integer: FileInfo fileInfo = new FileInfo(FILE_NAME); size = fileInfo.Length; Your program's output should look like the following: The size of the Word file is FILE_SIZE and the size of the Notepad file is FILE_SIZE The Notepad file is x% of the size of the Word file using System; using static System.Console; using System.IO; class FileComparison {     static void Main()     {         // Getting the file size of "Quote.txt"         FileInfo fileInfoQuoteTxt = new FileInfo("/root/sandbox/Quote.txt");         long lengthOfQuoteTxt = fileInfoQuoteTxt.Length;         // Getting the file size of "Quote.docx"         FileInfo fileInfoQuoteDocx = new FileInfo("/root/sandbox/Quote.docx");         long lengthOfQuoteDocx = fileInfoQuoteDocx.Length;         // Finding the percentage of the size of "Quote.txt" to the size of "Quote.docx"         double percentage = 100.0 * lengthOfQuoteTxt / lengthOfQuoteDocx;         // Printing the results with proper formatting         Console.WriteLine($"The size of the Word file is {lengthOfQuoteDocx} and the size of the Notepad file is {lengthOfQuoteTxt}");         Console.WriteLine($"The Notepad file is {percentage:F2}% of the size of the Word file");     }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter14: Files And Streams
Section: Chapter Questions
Problem 2E: Create a program named FileComparison that compares two files. First, use a text editor such as...
icon
Related questions
Question

Write the program FileComparison that compares two files. Two files have been provided for you, Quote.txt and Quote.docx, both containing movie quotes and are located in the /root/sandbox/ directory

Note: you will not be able to see the Quote.docx file.

Next write the file comparison application that displays the sizes of the two files as well as the ratio of their sizes to each other. To discover a file’s size, you can create a System.IO.FileInfo object using statements such as the following, where FILE_NAME is a string that contains the name of the file, and size has been declared as an integer:

FileInfo fileInfo = new FileInfo(FILE_NAME); size = fileInfo.Length;

Your program's output should look like the following:

The size of the Word file is FILE_SIZE and the size of the Notepad file is FILE_SIZE The Notepad file is x% of the size of the Word file

using System;
using static System.Console;
using System.IO;

class FileComparison
{
    static void Main()
    {
        // Getting the file size of "Quote.txt"
        FileInfo fileInfoQuoteTxt = new FileInfo("/root/sandbox/Quote.txt");
        long lengthOfQuoteTxt = fileInfoQuoteTxt.Length;

        // Getting the file size of "Quote.docx"
        FileInfo fileInfoQuoteDocx = new FileInfo("/root/sandbox/Quote.docx");
        long lengthOfQuoteDocx = fileInfoQuoteDocx.Length;

        // Finding the percentage of the size of "Quote.txt" to the size of "Quote.docx"
        double percentage = 100.0 * lengthOfQuoteTxt / lengthOfQuoteDocx;

        // Printing the results with proper formatting
        Console.WriteLine($"The size of the Word file is {lengthOfQuoteDocx} and the size of the Notepad file is {lengthOfQuoteTxt}");
        Console.WriteLine($"The Notepad file is {percentage:F2}% of the size of the Word file");
    }
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning