public List <File> SearchFile(Regex regex) { var files = new List <File>(); LoadFiles(); LoadSubDirectories(); ContainedFiles.ToList().ForEach(file => { if (regex.IsMatch(file.Name)) { files.Add(file); } } ); SubDirectories.ToList().ForEach(directory => { try { files.AddRange(directory.SearchFile(regex)); } catch (UnauthorizedAccessException e) { Debug.WriteLine(e.Source); } }); return(files); }
public override long GetSize() { long occupiedSpace = 0; LoadFiles(); LoadSubDirectories(); ContainedFiles.ToList().ForEach(file => occupiedSpace += file.GetSize()); SubDirectories.ToList().ForEach(directory => occupiedSpace += directory.GetSize()); return(occupiedSpace); }
public void LoadFiles() { ContainedFiles.Clear(); new DirectoryInfo(Path).GetFiles().ToList().ForEach(file => { if (CheckAttributes(file.Attributes)) { ContainedFiles.Add(new File(file.FullName)); } }); }