Bird
Raised Fist0

Which statement about the File class static methods is TRUE?

hard🧠 Conceptual Q10 of Q15
C Sharp (C#) - File IO
Which statement about the File class static methods is TRUE?
AFile.Move can move files across different drives
BFile.Copy overwrites the destination file by default without error
CFile.Delete does not throw an exception if the file does not exist
DFile.ReadAllText returns null if the file is empty
Step-by-Step Solution
Solution:
  1. Step 1: Analyze each statement

    ReadAllText returns empty string if file empty, not null. File.Copy throws if destination exists unless overwrite is true. File.Move cannot move files across different drives. File.Delete does not throw if file missing.
  2. Step 2: Identify the true statement

    Only the statement about File.Delete is true.
  3. Final Answer:

    File.Delete does not throw an exception if the file does not exist -> Option C
  4. Quick Check:

    True statement about File methods = D [OK]
Quick Trick: File.Delete does not throw if file missing [OK]
Common Mistakes:
MISTAKES
  • Thinking ReadAllText returns null
  • Assuming Copy overwrites silently
  • Believing Delete throws if file missing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes