/// <summary> /// 获取一个文件夹下的所有文件概要信息 /// </summary> /// <param name="folderPath"></param> /// <returns></returns> public List <FolderFileInfo> GetFiles(string folderPath) { var list = new List <FolderFileInfo>(); if (StringChecker.IsPhysicalPath(folderPath)) { try { var fileNames = Directory.GetFiles(folderPath); foreach (var fileName in fileNames) { var info = this.GetFileInfo(fileName); if (null != info) { list.Add(info); } } } catch (Exception e) { Console.WriteLine("异常信息:{0}", e.Message); } } return(list); }
/// <summary> /// 获取一个文件的子文件夹 /// </summary> /// <returns></returns> public List <FolderFileInfo> GetSubFolder(string currentPath) { var list = new List <FolderFileInfo>(); if (StringChecker.IsPhysicalPath(currentPath)) ///若路径符合要求 { try { var subFolderArr = Directory.GetDirectories(currentPath); foreach (var item in subFolderArr) { var folderInfo = this.GetFolderInfo(item); if (null != folderInfo) { list.Add(folderInfo); } } } catch (Exception e) { Console.WriteLine("异常信息:{0}", e.Message); } } return(list); }
/// <summary> /// /// </summary> /// <param name="filePath"></param> /// <returns></returns> public FolderFileInfo GetFileInfo(string filePath) { FolderFileInfo item = new FolderFileInfo(); if (StringChecker.IsPhysicalPath(filePath)) { item = FolderFileInfo.GetInst(filePath); } return(item); }
/// <summary> /// 是否有值 /// </summary> /// <param name="input"></param> /// <returns></returns> public static bool HasValue(string input) { return(!StringChecker.IsEmpty(input)); }