得到为最新写入文件以及该写入时间往前推20天,统计出所有在这个时间内写入的文件的大小!
public void BuildDirectoryNode(TreeNodeCollection fNodes, String fPath)
{
foreach (String directoryPath in Directory.GetDirectories(fPath))
{
TreeNode node = new TreeNode();
node.Text = new DirectoryInfo(directoryPath).Name; // 获取目录名称
node.Tag = directoryPath;
this.BuildDirectoryNode(node.Nodes, directoryPath); // 递归创建目录节点
this.BuildFileNode(node.Nodes, directoryPath); // 创建文件节点
fNodes.Add(node);
}
}
public void BuildFileNode(TreeNodeCollection fNodes, String fPath)
{
foreach (String filePath in Directory.GetFiles(fPath))
{
TreeNode node = new TreeNode();
FileInfo fi = new FileInfo(@filePath);
node.Text=fi.Name;//得到文件名
DateTime directoryCreateTime = fi.LastWriteTime;//得到文件的创建时间
long Size = fi.Length;//得到文件的大小
node.Text = node.Text +" "+ directoryCreateTime.ToString()+" "+Size.ToString();
node.Tag = filePath;
fNodes.Add(node);
}
}
代码如上 ,现在要得到文件中为最后写入的时间,然后在该时间的基础上往前推20天,最后统计这段时间内修改过的文件的大小。
表述还清楚吧 。呵呵 我是菜鸟哦
好像是用什么List 得到那个文件的集合,然后用什么SORT()方法判断最大的还是怎么的了 。
关键是我是菜鸟,不太懂写程序 。故来求大伙相助 、