使用Delphi在目录中找到最旧的文件的最快方法 [英] Quickest way to find the oldest file in a directory using Delphi

查看:134
本文介绍了使用Delphi在目录中找到最旧的文件的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI

我们有大量的远程计算机将视频捕获到磁盘驱动器上。每个摄像机都有自己的唯一目录,任何一个磁盘上最多可以有16个目录。

We have a large number of remote computers that capture video onto disk drives. Each camera has it's own unique directory and there can be up to 16 directories on any one disk.

我试图找到磁盘上最旧的视频文件,但使用 FindFirst / FindNext 来比较文件创建DateTime永远。有没有人知道在目录中找到最旧的文件的更有效的方法?

I'm trying to locate the oldest video file on the disk but using FindFirst/FindNext to compare the File Creation DateTime takes forever.

我们从HO中心远程连接到个人电脑。

Does anybody know of a more efficient way of finding the oldest file in a directory? We remotely connect to the pc's from a central HO location.

请问Pieter

更新

感谢大家的答案。最后我使用了以下内容。

Thank you all for the answers. In the end I used the following.


  1. 使用将驱动器('w:')映射到远程计算机windows.WNetAddConnection2

    //使用cmd.exe / c dir在远程计算机上执行dir

    //注意:驱动器盘符相对于远程电脑。 (psexec -w参数)

  2. psexec \\< IPAddress> -i / accepteula -wc:\windows\system32cmd.exe/ c dir q:\video / OD / TC / B> q:\dir.txt

  3. //读取第一行w:\dir.txt以获取该目录中最早的文件。

  4. //使用断开与远程计算机的连接windows.WNetCancelConnection2

  1. Map a drive ('w:') to the remote computer using windows.WNetAddConnection2
    //Execute dir on the remote computer using cmd.exe /c dir
    //NOTE: Drive letters are relative to the remote computer. (psexec -w parameter)
  2. psexec \\<IPAddress> -i /accepteula -w "c:\windows\system32" cmd.exe "/c dir q:\video /OD /TC /B > q:\dir.txt"
  3. //Read the first line of "w:\dir.txt" to get the oldest file in that directory.
  4. //Disconnect from the remote computer using windows.WNetCancelConnection2


推荐答案

您还可以尝试 FindFirstFileEx FindExInfoBasic 参数,在Windows 7或Server 2008 R2或更高版本上, FIND_FIRST_EX_LARGE_FETCH 其中应该提高性能

You could also try FindFirstFileEx with FindExInfoBasic parameter, and on Windows 7 or Server 2008 R2 or later, FIND_FIRST_EX_LARGE_FETCH which should improve performance.

这篇关于使用Delphi在目录中找到最旧的文件的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆