Help me with this C# assignment. I am unsure how to attach the files needed to t
ID: 3877166 • Letter: H
Question
Help me with this C# assignment. I am unsure how to attach the files needed to the code. I am using visual 2017.
Create a file that contains your favorite movie quote. Use a text editor such as Notepad and save the file as Quote.txt. Copy the file contents and paste them into a word-processing program such as Word. Save the file as Quote.doc. Write console 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 a statement such as the following, where FILE_NAME is a string that contains the name of the file:
FileInfo wordInfo = new FileInfo(FILE_NAME);
Save the file as FileComparison.cs.
Compile and run your program until it works and the output looks nice. Add the necessary documentation as described in Course Documents, and then attach your .cs file to this assignment. Do not attach the compiled files, attach only the .cs source code.
Explanation / Answer
# Every # denotes a comment.
class ReadFile
{
static void Main()
{
# reading text file.
FileInfo TextFile = new FileInfo(@"C:UsersDellDesktopQuote.txt");
# reading doc file.
FileInfo WordFile = new FileInfo(@"C:UsersDellDesktopQuote.doc");
# Evaluating their corresponding size.
long TextFile_length = new System.IO.FileInfo(TextFile ).Length;
long WordFile_length = new System.IO.FileInfo(WordFile ).Length;
# Printing their corresponding size.
System.Console.WriteLine("Text File Size ", TextFile_length );
System.Console.WriteLine("Word File Size ", WordFile_length );
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.