string path = @"C:\Users\"; IDirectory directory = new DirectoryInfo(path); IEnumerabledirectories = directory.GetDirectories();
string path = @"C:\Users\"; IDirectory directory = new DirectoryInfo(path); bool doesDirectoryExist = directory.Exists;The above code creates an instance of IDirectory interface for a specified path and checks if the directory exists. Package library: System.IO.FileSystem (https://docs.microsoft.com/en-us/dotnet/api/system.io.filesystem?view=net-5.0)