Question 7


Question

Multiple Choice

You are developing an applicaton. The applicaton includes a method named ReadFile that reads data from a fle. The ReadFile() method must meet the following requirements:

  1. It must not make changes to the data fle.
  2. It must allow other processes to access the data fle.
  3. It must not throw an excepton if the applicaton atempts to open a data fle that does not exist.
  4. You need to implement the ReadFile() method.
Which code segment should you use?

  • A. var fs = File.Open(Filename, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite));
  • B. var fs = File.Open(Filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
  • C. var fs = File.Open(Filename, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Write));
  • D. var fs = File.ReadAllLines(Filename));
  • E. var fs = File.ReadAllBytes(Filename));

Answer:

A