PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are developing an application. The application includes a method named ReadFile that reads data
from a file.
The ReadFile() method must meet the following requirements:
-It must not make changes to the data file.
-It must allow other processes to access the data file.
-It must not throw an exception if the application attempts to open a data file that does not exist.
You need to implement the ReadFileQ method. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

E.
Option E

Explanation:
Allows you to Open or Create, but not change the file. The folder however can be changed.

3 Comments on “Which code segment should you use?

  1. LS says:

    A.
    FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite)
    checks if the file exists – if it is, opens it, otherwise it creates new file and opens it.




    2



    0

Leave a Reply