Having trouble with this code in C#. Here is the error I get: An unhandled excep
ID: 3752886 • Letter: H
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 not find file 'quote.txt'.
I am pretty the file is where it should be: C:UserskeeneDocumentsVisual Studio 2015ProjectsProjectsFileComparison.csFileComparison.csinDebugquote.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);
}
}
Explanation / Answer
Please give the complete path of the file names or keep the files in the same project where the program is running.
The reason the system is unable to find the files
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.