Review Questions



What is the main reason for using files?


How are streams represented in C# and .NET?


In what context have you already used streams in previous chapters?


In which direction is the data moving when we talk about input from the program to a destination device or from a destination device to the program?


In what ways are text files and binary files similar? In what ways are they different?


Can you read a text file with a binary stream?


Suppose that you need to call just a single method only once in your program to manipulate a particular file in your file system. Which class would you use File or FileInfo (given that the method exists in both classes)? Why?


Suppose that you need to call several methods one after the other to manipulate one particular file in your file system. Which class would you use File or FileInfo (given that the methods exist in both classes)?


Consider the following two lines:

 FileInfo newFile = new FileInfo(@"C:\MyTestFiles\HorrorStory.txt"); Console.WriteLine("Length of file: { 0} ", newFile.Length); 

What will happen in the second line if C:\MyTestFiles\HorrorStory.txt does not already exist?


Briefly explain the difference between a file's full name and a file's relative name.


If a C# program ends normally, any unclosed files are automatically closed. Why then bother closing a file with the Close method?


How do you know that the ReadLine method of the StreamReader class has reached the end of the corresponding file?


Give another term for connecting a file to a stream.


What does the OpenWrite and OpenRead methods of the FileInfo class return?


C# Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: