Bird
0
0

Which of the following File class static methods checks if a file exists at a given path?

easy🧠 Conceptual Q11 of 15
C Sharp (C#) - File IO
Which of the following File class static methods checks if a file exists at a given path?
A<code>File.Exists(path)</code>
B<code>File.ReadAllText(path)</code>
C<code>File.Delete(path)</code>
D<code>File.Copy(source, destination)</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of each method

    File.Exists(path) checks if the file is present. File.ReadAllText(path) reads file content. File.Delete(path) deletes a file. File.Copy(source, destination) copies a file.
  2. Step 2: Identify the method that checks existence

    The method that returns a boolean indicating if the file exists is File.Exists(path).
  3. Final Answer:

    File.Exists(path) -> Option A
  4. Quick Check:

    Check file existence = File.Exists(path) [OK]
Quick Trick: Exists method returns true if file is present [OK]
Common Mistakes:
MISTAKES
  • Confusing ReadAllText with Exists
  • Using Delete to check existence
  • Thinking Copy checks file presence

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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