Files and Directories

Exercise: Writing to a file with using

Goal

Write to the local file Actors.txt

  1. Create a file stream called file with a using statement.
  2. Create a stream writer called writer using the file stram. This block must not use block syntax { ... } and instead by nested as the single statement under the previous using.
  3. Write each item in the list actors to the file on a new line. Use a foreach loop for this.
Page 15 of 20