Chapter Review Questions

  1. After writing everything you want to a file through a StreamWriter, what do you still need to remember to do?

  2. If you want to create a file path in an operating system independent way for file f.txt in directory d2, which is a subdirectory of d1, which is a subdirectory of the current directory, how would you do it?

  3. Windows uses \ as a path separator. If you want to write a literal directly for a Windows path, what issue is there in C#?

  4. In a file path, how do you refer to the parent directory of the current directory, without using the actual name of the parent directory?

  5. If you are reading from a StreamReader inFile, what is logically wrong with the following:

    if (inFile.ReadLine().Contains("!")) {
       Console.WriteLine(inFile.ReadLine() + "\n contains the symbol !"
    }