Question: Having trouble with this code in C#. Here is the error I get: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll Additional information: Could

Having trouble with this code in C#.

Here is the error I get:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: Could not find file 'quote.txt'.

I am pretty the file is where it should be: C:\Users\akeene\Documents\Visual Studio 2015\Projects\Projects\FileComparison.cs\FileComparison.cs\bin\Debug\quote.txt & quote.docx

Here's my code:

using System.IO; using System;

class FileComparison { static void Main() { // creating a fileinfo object for text file FileInfo textInfo = new FileInfo("quote.txt"); // creating a fileinfo object for word file FileInfo wordInfo = new FileInfo("quote.docx");

// getting size of text file double textSize = textInfo.Length; // getting size of word file double wordSize = wordInfo.Length;

// print the size of text file Console.WriteLine("Size of text file is " + textSize); // print the size of word file Console.WriteLine("Size of word file is " + wordSize);

// print the ratio of file sizes to each other Console.WriteLine("Ratio of text file size to word file size " + textSize / wordSize); Console.WriteLine("Ratio of word file size to text file size " + wordSize / textSize); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!