Introduces a PathInfo struct that contains a Directory or File path.
using Jacobi.Path;Allows for easy path concatenation:
PathInfo path = "root" / "folder" / "file.txt";All kinds of handy properties:
PathInfo path = "root" / "folder" / "file.txt";
var kind = path.Kind; // PathInfoKind.File
var dirName = path.DirectoryName; // 'root/folder'
var fileName = path.FileName; // 'file.txt'
var isRooted = path.IsRooted; // falseFolder specifics:
PathInfo path = "root" / "folder" / "sub";
var kind = path.Kind; // PathInfoKind.Directory
var fileNames = path.GetFileNames; // files in root/folder/subHelpers:
var currentDir = PathInfo.CurrentDirectory;
var userProfile = PathInfo.UserProfile;
var tempFile = PathInfo.TempFile;
var paths = PathInfo.PathEnvironmentVariable;Filtering / searching:
PathInfo path = "root" / "folder" / "sub";
PathFilter filter = new("*.txt") // find '*.txt'
{
SearchOption = SearchOption.AllDirectories, // this dir and sub dirs
MaxRecursion = 3, // max 3 levels deep
Kind = PathFilterKind.Files, // we want files as result
};
var results = path.Filter(filter);
// all '.txt' files in 'root/folder/sub' and max 3 levels deep sub folders.