/// <summary> /// 读取目录列表 /// </summary> public static List<FileItem> GetDirectoryItems(string path) { List<FileItem> list = new List<FileItem>(); string[] folders = Directory.GetDirectories(path); foreach (string s in folders) { FileItem item = new FileItem(); DirectoryInfo di = new DirectoryInfo(s); item.Name = di.Name; item.FullName = di.FullName; item.CreationDate = di.CreationTime; item.IsFolder = false; list.Add(item); } return list; }
/// <summary> /// 4.5读取文件列表 /// </summary> public static List<FileItem> GetFileItems(string path) { List<FileItem> list = new List<FileItem>(); string[] files = Directory.GetFiles(path); foreach (string s in files) { FileItem item = new FileItem(); FileInfo fi = new FileInfo(s); item.Name = fi.Name; item.FullName = fi.FullName; item.CreationDate = fi.CreationTime; item.IsFolder = true; item.Size = fi.Length; list.Add(item); } return list; }