C# FileInfo, DirectoryInfo获取文件信息。
using System.IO;
/**********FileInfo**********/
// 文件
string path = "D:\\test\\001.txt";
FileInfo fileInfo = new FileInfo(path);
// 获取文件的完成路径, "D:\test"
string filepath = fileInfo.DirectoryName;
// 获取文件或文件夹的完整路径名, "D:\test\001.txt"
string fullname = fileInfo.FullName;
// 获取文件名, "001.txt"
string name = fileInfo.Name;
// 获取文件的字节大小
long length = fileInfo.Length;
// 获取或设置文件或文件夹的创建日期
DateTime createionTime = fileInfo.CreationTime;
// 获取或设置最后一次访问文件或文件夹的时间
DateTime lastAccessTime = fileInfo.LastAccessTime;
// 获取或设置最后一次修改文件夹或文件夹的时间
DateTime lastWriteTime = fileInfo.LastWriteTime;
/**********DirectoryInfo**********/
// 文件夹
string path2 = "D:\\test";
DirectoryInfo directoryInfo = new DirectoryInfo(path2);
// 获取文件或文件夹的完整路径名, "D:\test"
string fullname2 = directoryInfo.FullName;
// 获取文件名, "test"
string name2 = directoryInfo.Name;
// 获取或设置文件或文件夹的创建日期
DateTime createionTime2 = directoryInfo.CreationTime;
// 获取或设置最后一次访问文件或文件夹的时间
DateTime lastAccessTime2 = directoryInfo.LastAccessTime;
// 获取或设置最后一次修改文件夹或文件夹的时间
DateTime lastWriteTime2 = directoryInfo.LastWriteTime;
CreationTime, LastAccessTime, LastWriteTime 是可以被修改的,请参阅:https://www.hicsharp.com/a/09404bff-4ef9-45a6-be01-6c490076c15e