Complete the code to get the file name from the full path.
string filePath = @"C:\Users\Public\Documents\report.pdf"; string fileName = System.IO.Path.[1](filePath); Console.WriteLine(fileName);
The GetFileName method extracts the file name from a full file path.
Complete the code to check if a directory exists at the given path.
string dirPath = @"C:\Temp\Logs"; bool exists = System.IO.Directory.[1](dirPath); Console.WriteLine(exists);
The Exists method checks if the directory exists and returns true or false.
Fix the error in the code to combine two parts of a file path correctly.
string folder = @"C:\Users\Public"; string file = "data.txt"; string fullPath = System.IO.Path.[1](folder, file); Console.WriteLine(fullPath);
The Combine method correctly joins folder and file names into a valid path.
Fill both blanks to create a dictionary with file names as keys and their extensions as values from a list of file paths.
var files = new List<string> { @"C:\Docs\file1.txt", @"D:\Music\song.mp3" };
var fileDict = files.ToDictionary(f => System.IO.Path.[1](f), f => System.IO.Path.[2](f));GetFileName extracts the file name for the dictionary key, and GetExtension extracts the file extension for the value.
Fill the blanks to create a dictionary with uppercase directory names as keys and the count of files inside as values.
var dirs = new List<string> { @"C:\Temp", @"D:\Data" };
var dirInfo = dirs.ToDictionary(d => System.IO.Path.[1](d).ToUpper(), d => System.IO.Directory.[2](d).Length);GetFileName gets the last folder name to uppercase for the key, GetFiles returns files to count for the value.