public FileInfo GetFileInfo(string path) { var info = new System.IO.FileInfo(path); if (!info.Exists) return null; return new FileInfo { Path = path.Replace(Folder, String.Empty), Created = info.CreationTime, Modified = info.LastWriteTime, Size = info.Length }; }
public IEnumerable<FileInfo> GetFileList(string searchPattern = null, int? limit = null) { if (String.IsNullOrEmpty(searchPattern)) searchPattern = "*"; var list = new List<FileInfo>(); foreach (var path in Directory.GetFiles(Folder, searchPattern, SearchOption.AllDirectories).Take(limit ?? Int32.MaxValue)) { var info = new System.IO.FileInfo(path); if (!info.Exists) continue; list.Add(new FileInfo { Path = path.Replace(Folder, String.Empty), Created = info.CreationTime, Modified = info.LastWriteTime, Size = info.Length }); } return list; }
public IEnumerable <FileInfo> GetFileList(string searchPattern = null, int?limit = null, DateTime?maxCreatedDate = null) { if (String.IsNullOrEmpty(searchPattern)) { searchPattern = "*"; } if (!maxCreatedDate.HasValue) { maxCreatedDate = DateTime.MaxValue; } var list = new List <FileInfo>(); foreach (var path in Directory.GetFiles(Folder, searchPattern, SearchOption.AllDirectories)) { var info = new System.IO.FileInfo(path); if (!info.Exists || info.CreationTime > maxCreatedDate) { continue; } list.Add(new FileInfo { Path = path.Replace(Folder, String.Empty), Created = info.CreationTime, Modified = info.LastWriteTime, Size = info.Length }); if (list.Count == limit) { break; } } return(list); }