Files and Directories

Exercise: Writing to a file

Goal

Write to the local file Actors.txt

  1. Create a file stream called file using the local file "Movies.txt" to overwrite the file
  2. Create a stream writer called writer using the file stream
  3. Write each item in the list actors to the file on a new line. Use a foreach loop for this
  4. After the loop, close the reader.
Page 12 of 20