Recall & Review
beginner Click to reveal answer
What is a file path in C#?
A file path is a string that shows the location of a file or folder on your computer. It tells the program where to find or save files.
beginner Click to reveal answer
How do you combine parts of a file path safely in C#?
Use
Path.Combine() method. It joins parts of a path with the correct separator for your system, avoiding errors.beginner Click to reveal answer
What does
Directory.CreateDirectory() do?It creates a new folder (directory) at the specified path. If the folder already exists, it does nothing and does not throw an error.
beginner Click to reveal answer
How can you check if a file exists in C#?
Use
File.Exists(path). It returns true if the file is there, otherwise false.intermediate Click to reveal answer
What is the difference between
Directory.GetFiles() and Directory.GetDirectories()?Directory.GetFiles() returns a list of files in a folder. Directory.GetDirectories() returns a list of subfolders inside a folder.Which method safely joins multiple parts of a file path in C#?
✗ Incorrect
Path.Combine() joins path parts using the correct separator for the operating system.
What does Directory.CreateDirectory() do if the folder already exists?
✗ Incorrect
It does nothing and does not throw an error if the folder exists.
How do you check if a file exists at a given path?
✗ Incorrect
File.Exists(path) returns true if the file exists, false otherwise.
Which method lists all files inside a directory?
✗ Incorrect
Directory.GetFiles() returns an array of file names in the directory.
What is the correct way to get the file name from a full path?
✗ Incorrect
Path.GetFileName() extracts the file name from a full file path.
Explain how to create a new directory and check if it exists in C#.
Think about methods to create and verify folders.
You got /3 concepts.
Describe how to safely build a file path from folder and file name parts.
Focus on combining path parts without errors.
You got /3 concepts.
