Review Questions

   


1:

What is the main reason for using files?

2:

How are streams represented in C# and .NET?

3:

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

4:

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?

5:

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

6:

Can you read a text file with a binary stream?

7:

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?

8:

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)?

9:

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?

10:

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

11:

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

12:

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

13:

Give another term for connecting a file to a stream.

14:

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

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net