Bird
Raised Fist0

Which C# class is used to check if a directory exists on your computer?

easy🧠 Conceptual Q11 of Q15
C Sharp (C#) - File IO
Which C# class is used to check if a directory exists on your computer?
APath
BFile
CDirectory
DStreamReader
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of Directory class

    The Directory class provides methods to work with folders, including checking if they exist.
  2. Step 2: Identify the correct method for existence check

    Directory.Exists(path) returns true if the folder exists, which is what we need.
  3. Final Answer:

    Directory -> Option C
  4. Quick Check:

    Directory = Folder check [OK]
Quick Trick: Use Directory class to manage folders easily [OK]
Common Mistakes:
MISTAKES
  • Confusing File class with Directory for folders
  • Using Path class to check existence
  • Trying to read folder like a file

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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