exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 1 question 7 discussion

Actual exam question from Microsoft's 70-483
Question #: 7
Topic #: 1
[All 70-483 Questions]

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 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);
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
FileMode.OpenOrCreate - Specifies that the operating system should open a file if it exists; otherwise, a new file should be created. If the file is opened with
FileAccess.Read, FileIOPermissionAccess.Read permission is required. If the file access is FileAccess.Write, FileIOPermissionAccess.Write permission is required. If the file is opened with FileAccess.ReadWrite, both FileIOPermissionAccess.Read and FileIOPermissionAccess.Write permissions are required.
FileShare.ReadWrite - Allows subsequent opening of the file for reading or writing. If this flag is not specified, any request to open the file for reading or writing (by this process or another process) will fail until the file is closed. However, even if this flag is specified, additional permissions might still be needed to access the file.
References:
http://msdn.microsoft.com/pl-pl/library/system.io.fileshare.aspx http://msdn.microsoft.com/en-us/library/system.io.filemode.aspx

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
apostolin
Highly Voted 5 years, 11 months ago
The correct answer is: A.
upvoted 12 times
...
zzMichielzz
Most Recent 4 years, 10 months ago
A. I checked this.
upvoted 1 times
...
cshine
4 years, 11 months ago
(A) is correct
upvoted 1 times
...
lh2607
5 years ago
A is correct
upvoted 1 times
...
robinnirola
5 years, 3 months ago
Ans : A
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...