in c # i need to 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 I am getting the error Test Case Incomplete FileComparison calculates the difference between the .txt and .docxfiles Input Output Unhandled Exception: System.IO.FileNotFoundException: Could not find file '/root/sandbox/ directory/Quote.txt'. File name: '/root/sandbox/ directory/Quote.txt' at System.IO.FileInfo.get_Length () [0x0001d] in <7b90a8780ac4414295b539b19eea7eea>:0 at (wrapper remoting-invoke-with-check) System.IO.FileInfo.get_Length() at FileComparison.Main () [0x00013] in <15c3c41757e6485b954d6d46d24be6b5>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not find file '/root/sandbox/ directory/Quote.txt'. File name: '/root/sandbox/ directory/Quote.txt' at System.IO.FileInfo.get_Length () [0x0001d] in <7b90a8780ac4414295b539b19eea7eea>:0 at (wrapper remoting-invoke-with-check) System.IO.FileInfo.get_Length() at FileComparison.Main () [0x00013] in <15c3c41757e6485b954d6d46d24be6b5>:0 Results The size of the Word file is 20693and the size of the Notepad file is (27|28)The Notepad file is (0.13|0.14) % of the size of the Word file my code so far is using System; using static System.Console; using System.IO; class FileComparison { static void Main() { string quoteTxtFile = "/root/sandbox/ directory/Quote.txt"; string quoteDocxFile = "/root/sandbox/ directory/Quote.docx"; FileInfo txtFileInfo = new FileInfo(quoteTxtFile); long txtFileSize = txtFileInfo.Length; FileInfo docxFileInfo = new FileInfo(quoteDocxFile); long docxFileSize = docxFileInfo.Length; WriteLine($"The size of the Word file is {docxFileSize} and the size of the Notepad file is {txtFileSize}"); double ratio = (double)txtFileSize / docxFileSize; WriteLine($"The Notepad file is {ratio:P} of the size of the Word file"); } }
in c # i need to
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
I am getting the error
Test Case
Incomplete
FileComparison calculates the difference between the .txt and .docxfiles
Input
Output
Unhandled Exception:
System.IO.FileNotFoundException: Could not find file '/root/sandbox/ directory/Quote.txt'.
File name: '/root/sandbox/ directory/Quote.txt'
at System.IO.FileInfo.get_Length () [0x0001d] in <7b90a8780ac4414295b539b19eea7eea>:0
at (wrapper remoting-invoke-with-check) System.IO.FileInfo.get_Length()
at FileComparison.Main () [0x00013] in <15c3c41757e6485b954d6d46d24be6b5>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not find file '/root/sandbox/ directory/Quote.txt'.
File name: '/root/sandbox/ directory/Quote.txt'
at System.IO.FileInfo.get_Length () [0x0001d] in <7b90a8780ac4414295b539b19eea7eea>:0
at (wrapper remoting-invoke-with-check) System.IO.FileInfo.get_Length()
at FileComparison.Main () [0x00013] in <15c3c41757e6485b954d6d46d24be6b5>:0
Results
The size of the Word file is 20693and the size of the Notepad file is (27|28)The Notepad file is (0.13|0.14) % of the size of the Word file
my code so far is

Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images









