using System.IO; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; namespace ConsoleInterface { public static class FileSystemHelpers { public static ILogger Logger = NullLogger.Instance; /// /// Creates the directory if it doesn't exist. /// /// The destination directory's path. public static void CreateDestinationDirectory(string directoryPath) { if (Directory.Exists(directoryPath)) { return; } Logger.LogWarning("Output directory does not exist. Creating."); Directory.CreateDirectory(directoryPath); } /// /// CheckIfFileExists checks if file exists. /// /// The path of the file to be checked. /// Returns true if file exists, False otherwise. public static bool CheckIfFileExists(string filePath) { var result = File.Exists(filePath); Logger.LogDebug(result ? $"CheckIfFileExists - {filePath} exists." : $"CheckIfFileExists - {filePath} doesn't exists."); return result; } } }